usadarts Posted August 20, 2007 Share Posted August 20, 2007 Receiving the following error: I cannot update database: "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 'WHERE `rrn` =1' at line 1 $sql = "UPDATE `homepage` SET `date` = $date, `comments` = $newcomments WHERE `rrn` =1"; Link to comment https://forums.phpfreaks.com/topic/65745-solved-syntax-error-during-sql-update/ Share on other sites More sharing options...
btherl Posted August 20, 2007 Share Posted August 20, 2007 $date_sql = "'" . mysql_real_escape_string($date) . "'"; $newcomments_sql = "'" . mysql_real_escape_string($newcomments) . "'"; $sql = "UPDATE `homepage` SET `date` = $date_sql, `comments` = $newcomments_sql WHERE `rrn` =1"; If you've already escaped your strings, you can skip that. But you need the single quotes around strings. Link to comment https://forums.phpfreaks.com/topic/65745-solved-syntax-error-during-sql-update/#findComment-328418 Share on other sites More sharing options...
Fadion Posted August 20, 2007 Share Posted August 20, 2007 $sql = "UPDATE homepage SET date='$date', comments='$newcomments' WHERE rrn='1'"; U dont need smart quotes for tables names or columns, but u need single quotes for values. Link to comment https://forums.phpfreaks.com/topic/65745-solved-syntax-error-during-sql-update/#findComment-328421 Share on other sites More sharing options...
MadTechie Posted August 20, 2007 Share Posted August 20, 2007 WHERE `rrn` ='1' Link to comment https://forums.phpfreaks.com/topic/65745-solved-syntax-error-during-sql-update/#findComment-328423 Share on other sites More sharing options...
usadarts Posted August 20, 2007 Author Share Posted August 20, 2007 Thank you all Link to comment https://forums.phpfreaks.com/topic/65745-solved-syntax-error-during-sql-update/#findComment-328426 Share on other sites More sharing options...
btherl Posted August 20, 2007 Share Posted August 20, 2007 Note that you should not add quotes around 1 if rrn is an integer. Link to comment https://forums.phpfreaks.com/topic/65745-solved-syntax-error-during-sql-update/#findComment-328507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.