Jump to content

[SOLVED] Syntax Error During SQL Update


usadarts

Recommended Posts

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

$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.

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.