...

View Full Version : Why has this error occured?



Democrazy
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.

Fou-Lu
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.

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

Solved.

tangoforce
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum