Jump to content

keep getting error when UPDATE mysql statement plz help.


loshyt

Recommended Posts

ive tried to write the $sql in so many ways and this looks the best and its still not working

and ive checked the correct syntax but still.

 

this is how i wrote:

$sql2 = "UPDATE `tvchaty`.`episodes` SET `showid` = ".($showid).", `epname` = ".($epname).", `season` = ".($season).", `episode` = ".($episode).", `info` = ".($info).", `airdate` = ".($airdate).", `directwatch` = ".($directwatch)." WHERE `episodes`.`id` = ".($id)." LIMIT 1;";

 

 

this is the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Prideses, `season` = 6, `episode` = 11, `info` = , `airdate` = 2010-11-01, `dire' at line 1

 

what could be the problem?

 

tnx....

Always print out the entire query.  If you had done so, you would see that there are no quotes around your string variables:

$sql2 = "UPDATE `tvchaty`.`episodes` SET `showid` = '".$showid."', `epname` = '".$epname."', `season` = '".$season."', `episode` = '".$episode."', `info` = '".$info.'", `airdate` = '".$airdate."', `directwatch` = '".$directwatch.'" WHERE `episodes`.`id` = ".$id." LIMIT 1";

  Also, don't call your sql $sql2, give it a meaningful name.

 

-Dan

String values should be quoted in the query string, whereas numeric values should not. I've kind of guessed at which fields will hold strings, so you may need to adjust it a bit.

 

$sql2 = "UPDATE `tvchaty`.`episodes` SET `showid` = $showid, `epname` = '$epname', `season` = $season, `episode` = $episode, `info` = '$info', `airdate` = '$airdate', `directwatch` = '$directwatch' WHERE `episodes`.`id` = $id LIMIT 1"; 

wow thanks guys @Pikachu2000 youve guessed correctly and now i think i will quote everything...

and @ManiacDan i didnt call it in a meaningful name becuse its a second $sql in a page that update

so i could not go wrong with what it does..

 

 

thanks again to you two...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.