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 `id` [closed]

You cannot have a WHERE clause in a basic INSERT syntax. What you really want, i think, is an UPDATE statement,

UPDATE cafes SET deal="$deal" WHERE id = $id

As a sidenote, the query is vulnerable with SQL Injection if the value(s) of the variables came from the outside. Please take a look at the article below to learn how to prevent from it. By using PreparedStatements you can get rid of using single quotes around values.

Leave a Comment