[SOLVED] Parse Error with mySql Delete statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
bironeb
Forum Commoner
Posts: 59
Joined: Thu Nov 20, 2003 12:02 pm

[SOLVED] Parse Error with mySql Delete statement

Post 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?
Last edited by bironeb on Wed Apr 07, 2004 12:29 pm, edited 1 time in total.
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post 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']."'";
Last edited by lostboy on Wed Apr 07, 2004 1:45 pm, edited 1 time in total.
phait
Forum Commoner
Posts: 46
Joined: Wed Apr 07, 2004 4:41 am
Location: watford / leicester, UK

Post 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
User avatar
bironeb
Forum Commoner
Posts: 59
Joined: Thu Nov 20, 2003 12:02 pm

Post by bironeb »

Thanks guys. its working great with your corrections.
Post Reply