loshyt Posted November 16, 2010 Share Posted November 16, 2010 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.... Quote Link to comment https://forums.phpfreaks.com/topic/218854-keep-getting-error-when-update-mysql-statement-plz-help/ Share on other sites More sharing options...
ManiacDan Posted November 16, 2010 Share Posted November 16, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/218854-keep-getting-error-when-update-mysql-statement-plz-help/#findComment-1135006 Share on other sites More sharing options...
Pikachu2000 Posted November 16, 2010 Share Posted November 16, 2010 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"; Quote Link to comment https://forums.phpfreaks.com/topic/218854-keep-getting-error-when-update-mysql-statement-plz-help/#findComment-1135007 Share on other sites More sharing options...
ManiacDan Posted November 16, 2010 Share Posted November 16, 2010 I simply quoted everything, where Pikachu guessed. Quoting numbers is technically wrong, but it won't hurt. Do it properly though. Quote Link to comment https://forums.phpfreaks.com/topic/218854-keep-getting-error-when-update-mysql-statement-plz-help/#findComment-1135025 Share on other sites More sharing options...
loshyt Posted November 16, 2010 Author Share Posted November 16, 2010 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... Quote Link to comment https://forums.phpfreaks.com/topic/218854-keep-getting-error-when-update-mysql-statement-plz-help/#findComment-1135057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.