以下の PHP コードは、エラー コードを報告します。
$id = $_SESSION['sno'];
$q = mysql_query("select * from messages where seen=0 and to=$id");
if(!$q){die("critical failure: ".mysql_error());}
報告されたエラーは次のとおりです。
critical failure: 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 'to=1' at line 1
'to=1' は、$_SESSION['sno'] が 1 に設定されていることを示します