You should be checking to see if [man]mysql_query/man returns boolean FALSE (indicating an error has occurred) and, if so, outputting and/or logging (as desired) the error message returned by the MySQL server (see [man]mysql_error/man - also note it's often useful to output/log the SQL query itself as well).
In your case, the error is being caused by the fact that all strings must be delimited with quotes (which you have omitted).
Also, note that user-supplied data should never be placed directly into a SQL query string else your code will be vulnerable to SQL injection attacks and/or just plain SQL errors. Instead, you must first sanitize it with a function such as [man]mysql_real_escape_string/man.