I'm trying to do a very simple UPDATE with PHP, like this:
$nlk = $lk + "1";
mysql_query("UPDATE posts SET like = '".$nlk."' WHERE id = '".$cid."'") or die(mysql_error());
$lk is a the value gotten from the field like, which is default 0.
$cid is a value from an id field, which is on auto_increment.
I get this 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 'like = '1' WHERE id = '45'' at line 1
What is the issue here?
like is a reserved word. You need to surround it with back-ticks
mysql_query("UPDATE posts SET `like` = '".$nlk."' WHERE id = '".$cid."'") or die(mysql_error());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With