Hello and welcome to our community! Is this your first visit?
Register
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
    Posts
    1
    Thanks
    0
    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 09:14 PM.

  • #2
    $object->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Jun 2003
    Posts
    3,092
    Thanks
    2
    Thanked 23 Times in 23 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:
    print($sql); 
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    SNAP to it!

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,436 Times in 4,401 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:
    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.


  •  

    Posting Permissions

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