For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.
For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data.
Use mysql_num_rows() to find out how many rows were returned for a SELECT statement or mysql_affected_rows() to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement.
mysql_query() will also fail and return FALSE if the user does not have permission to access the table(s) referenced by the query.
你忘了你的錯誤檢查。爲什麼每個人都會忘記錯誤檢查? –
[錯誤:警告:mysql_num_rows()的可能的重複期望參數1是資源,在第27行C:\ xampp \ htdocs \ messages.php中給出的布爾值](http://stackoverflow.com/questions/6936185/error -warning-mysql-num-rows-expects-parameter-1-to-resource-boolean-give)(更不用提半個_million_其他問題) –