Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Thanked 0 Times in 0 Posts

    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 10:14 PM.

  2. #2
    Super Moderator vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Thanked 43 Times in 43 Posts
    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:
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  3. #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    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:
    echo "<hr/>DEBUG SQL: " . $sql . "<hr/>\n";
    and then show us what that debug line shows you.
    Be yourself. No one else is as qualified.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts