Driving me nuts! any clues

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
jjl
Forum Newbie
Posts: 13
Joined: Wed May 14, 2008 12:31 am

Driving me nuts! any clues

Post by jjl »

I keep getting the smurf error from this simple code

$sql = "update $table_name set usergroup = '$approved' where username = '$username' ";

The error is

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 'set usergroup = 'Users' where username = 'dodo'' at line 1

The only thing I can see in the error message is the different quotes around 'dodo" . The above message is a cut and paste so there are no typos.

Any help greatly appreciated.
Thanks
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Driving me nuts! any clues

Post by Christopher »

If you do echo $sql; what is the actual SQL statement being executed?
(#10850)
jjl
Forum Newbie
Posts: 13
Joined: Wed May 14, 2008 12:31 am

Re: Driving me nuts! any clues

Post by jjl »

Thanks, I did not know that was possible. The result of echo $sql was

update set usergroup = 'Users' where username = 'dodo'

So the "table name" is missing from the update statement. I replaced it manually rather than using a var and it works fine.

Thanks for the tip on the echo $sql. I will use that alot from now on.
Post Reply