PHP - Mysql_error
can someone enlighten me as to what is wrong with this snippet
Code: [Select] $message_sql = "select * from messages where to_id=$id and read='no'"; $message_query = mysql_query($message_sql); $message_num_rows = mysql_num_rows($message_query); i get this error Code: [Select] PHP Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given what its basically telling me is that the "read" filed doesnt exist..because when I take it out of my query, the query works fine...however I do have a "read" field in my db with value of "no" stored in it..so im not sure why its telling me that it doesnt exist.. Similar TutorialsI am currently using my own error handler so i can log all mysql errors into a mysql table: mysql_query('select data from table')or trigger_error(mysql_error(),256); If there's an error i need to know the line number where the mysql_query function was called. Is it possible to instead use this code: mysql_query('select data from table'); but somehow transparently log a mysql error and the line number if there is an error in the query? thanks |