Yes, as samudasu said, there's an error in your SQL query.
If you dynamically create your SQL query, you can put a
$cmd = "SELECT * FROM mytable WHERE ".$somevar."=".$somevalue;
print $cmd;
Before the mysql_query() call.
This will show you the exact SQL query you're trying to run.
If the syntax error is not that obvious at that time, then try to add a
just after your mysql_query() call.
This will show you the exact error inside the SQL query.