View Full Version : Why has this error occured?

09-10-2011, 06:59 AM
$email = $_POST['e-mail'];
query = "delete from testdb.newsletters where email="$email";

PHP Parse error: syntax error, unexpected T_VARIABLE

Why has this error occurred? I am so sure the error revolves around the way I've used '"$email"' and the error can be fixed with two more or less bytes lol.

09-10-2011, 07:05 AM
It has occurred because you're structure of the (attempted) variable is incorrect. That should be:

$query = "DELETE FROM testdb.newsletters WHERE email = '$email'";

Case of query commands is purely for readability; it is not required in SQL.

09-10-2011, 07:06 AM
"$email" should have been '$email'.


09-10-2011, 12:16 PM
For an explanation about how to use quotation marks in php see the link about quotes in my signature below.