Vote count:
0
Hi i have a reads counter, but i always get an MySQL error:
MySQL 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 ''reads') VALUES ('2') WHERE id = '20'' at line 1
$reads = $row['reads']+1;
$newsid = $row['id'];
if(!$query = $db->query("UPDATE cmsss_news_articles SET reads = '$reads' WHERE id = '$newsid'")) {
echo "<center><b>Error, cant update row</b></center>";
}
Can you please help me where is the mistake?
asked 2 mins ago
1 Answer
Vote count:
0
reads
is a reserved word in MySQL. Escape it with backticks.
answered 13 secs ago
Aucun commentaire:
Enregistrer un commentaire