Page 1 of 1

[SOLVED] Parse Error with mySql Delete statement

Posted: Wed Apr 07, 2004 12:14 pm
by bironeb
Here is the error im getting:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' on line 26

Here is my Delete Statement:

Code: Select all

$sql = "DELETE FROM $table_name WHERE user_id ='$_POST[user_id ]'";

I don't see whats wrong with this... And the error confuses me about the expecting ] ....

Any ideas?

Posted: Wed Apr 07, 2004 12:19 pm
by lostboy
You have a blank space after the word user_id. I would also suggest that it be changed to add single quotes inside the square brackets

Code: Select all

$sql = "DELETE FROM $table_name WHERE user_id ='".$_POST['user_id']."'";

Posted: Wed Apr 07, 2004 12:20 pm
by phait
hi,
looks like you got a whitespace after the 'user_id' part, in fact you definitelty have cos I just copied it from your code that you put up. Try this instead:

Code: Select all

$sql = "DELETE FROM $table_name WHERE user_id ='$_POSTїuser_id]'";
HTH

Posted: Wed Apr 07, 2004 12:29 pm
by bironeb
Thanks guys. its working great with your corrections.