Bug #25582 Error in SQL syntax put in both warning and error report list
Submitted: 12 Jan 2007 12:40 Modified: 17 Jan 2007 19:54
Reporter: jocelyn fournier (Silver Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.14-beta, 5.0.34-BK OS:Linux (Linux)
Assigned to: Chad MILLER CPU Architecture:Any

[12 Jan 2007 12:40] jocelyn fournier
Description:
Hi,

If a SQL error occurs, this is put in both error and warning report list.

Regards,
  Jocelyn Fournier
  http://www.mesdiscussions.net

How to repeat:
mysql> select;
ERROR 1064 (42000): 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 '' at line 1

mysql> show warnings;
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                            |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1064 | 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 '' at line 1 | 
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> show errors;
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message                                                                                                                                            |
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
| Error | 1064 | 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 '' at line 1 | 
+-------+------+----------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

Suggested fix:
This should only be put in the error report list.
[12 Jan 2007 13:03] Valeriy Kravchuk
Verified also on 5.0.34-BK:

mysql> select ;
ERROR 1064 (42000): 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 '' at
line 1
mysql> show warnings\G
*************************** 1. row ***************************
  Level: Error
   Code: 1064
Message: 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 '' at line 1
1 row in set (0.00 sec)

mysql> show errors\G
*************************** 1. row ***************************
  Level: Error
   Code: 1064
Message: 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 '' at line 1
1 row in set (0.00 sec)

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.0.34-debug |
+--------------+
1 row in set (0.00 sec)
[17 Jan 2007 18:33] Chad MILLER
I'm not sure this is a bug.  I think it's modeled on syslog, where limiting to severity N also show N-and-more-important.  In non-strict mode, everything that would be an error in strict mode is instead merely a warning.

Neither is this limited to syntax errors, which would be strange indeed.
[17 Jan 2007 19:54] Chad MILLER
From the documentation:  
"SHOW WARNINGS shows the error, warning, and note messages that resulted from the last statement that generated messages, or nothing if the last statement that used a table generated no messages"

http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html
[26 Jul 2008 21:59] Michael Jones
I got the same error because I had not declared the variable $table in my config.php.  The register.php file was asking for username on $table, but could not locate it.  A similar error to yours occurred.  

In order to figure out if you did the same thing, look at what the code is asking for from the database and make sure it is declared, either in the page you're on, or in an include like config.php is for me.