Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2012, 09:04 PM   PM User | #1
17mayis
New to the CF scene

 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
17mayis is an unknown quantity at this point
could not run the query

hello ppl i'm new here i have the assingments and i been working on its a project for the animal zoo to add animal , species enclosure etc but when i try to add the data into the forum i get the error says

could not run the query

i took 3 screen shot to give u better idea what and i have my msql set up right with the connection.inc.php file





Last edited by 17mayis; 01-07-2012 at 09:14 PM..
17mayis is offline   Reply With Quote
Old 01-08-2012, 01:48 AM   PM User | #2
vinyl-junkie
$object->toCD-R(LP);


 
vinyl-junkie's Avatar
 
Join Date: Jun 2003
Posts: 3,054
Thanks: 2
Thanked 22 Times in 22 Posts
vinyl-junkie is on a distinguished road
Remove the quotes from the VALUES fields in your query. The quotes around the fields treat those values as literals; e.g., the literal $Animal_Name, instead of the value the variable represents.

Another thing you can do to debug something like this is to print to the screen the exact sql query that you're trying to execute. It's been a while since I've written PHP, but I believe you do it like this:

PHP Code:
print($sql); 
__________________
Music Around The World - Collecting tips, trade
and want lists, album reviews, & more
SNAP to it!
vinyl-junkie is offline   Reply With Quote
Old 01-08-2012, 08:47 PM   PM User | #3
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,064 Times in 4,033 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Vinyl-Junkies answer is wrong.

Oh, his point '$Animal_Name' will be seen as MySQL as a string literal is correct. But you *WANT* it to be seen as a string literal!!! Your INSERT will never work if those are not seen as MySQL as string literals. Without the apostrophes, the values can only be numbers or the names of columns in the DB.

Do this:

Just *AFTER* you assign the sql string to the $sql variable, add in a DEBUG line:
Code:
echo "<hr/>DEBUG SQL: " . $sql . "<hr/>\n";
and then show us what that debug line shows you.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:40 PM.


Advertisement
Log in to turn off these ads.