RE: [PHP] error when trying to delete a record
| From: | Jay Blanchard | Date: | Mon, 11 Jul 2005 13:56:42 +0000 |
| Subject: | RE: [PHP] error when trying to delete a record | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-218433@lists.php.net to get a copy of this message | ||
[snip]
$query= "DELETE FROM sheet1 WHERE id=$id";
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 '' at line 1
[/snip]
try...
$query= "DELETE FROM sheet1 WHERE id = '".$id."' ";
Note the single quotes around conditional data. Imagine if $id = 1 and
you did your original query, it would read...
$query= "DELETE FROM sheet1 WHERE id=1";
Which is where id = TRUE. You could end up deleting all of the records
in the database.