Page 1 of 1

Driving me nuts! any clues

Posted: Sat May 31, 2008 10:43 pm
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

Re: Driving me nuts! any clues

Posted: Sat May 31, 2008 10:46 pm
by Christopher
If you do echo $sql; what is the actual SQL statement being executed?

Re: Driving me nuts! any clues

Posted: Sat May 31, 2008 11:18 pm
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.