mysql_query()
returns Boolean False
when it fails with an error. Since there is an error in your SQL, $sql
equals False
.
mysql_num_fields()
expects you to pass in a result set, not a Boolean value, hence the error: ERROR: mysql_num_fields() expects parameter 1 to be resource, boolean given
.
PHP関数である mysql_real_escape_string()
をクエリに直接組み込んでいます。これの代わりに:
"WHERE main_table.matric = mysql_real_escape_string($_POST[matric_no]'");"
matric
が数字であると仮定して、これ以上のものを試してみましょう:
"WHERE main_table.matric = ". mysql_real_escape_string($_POST[matric_no]);
PHPで mysql_error()
関数を使用して、MySQLがSQLでのエラーの内容を確認してください。