Reputation: 339
I have a delete function implemented on my website. A normal customer can delete his/her account and this updates a "delete" field from 0 to 1. My table is called "users" and everything seem to work fine. However when I test the delete function I get the following 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 'delete='1' WHERE email='[email protected]'' at line 1"
The code for my update query is shown below:
mysql_query("UPDATE users SET delete='1' WHERE email='$email'")or die(mysql_error());
Your help will be much appreciated.
Upvotes: 0
Views: 91
Reputation: 219794
DELETE
is a MySQL reserved keyword. If you're going to name a column after that you must wrap it in ticks;
mysql_query("UPDATE users SET `delete`='1' WHERE email='$email'")or die(mysql_error());
You really shouldn't use DELETE
as a column identifier. I strongly recommend changing it.
Upvotes: 4