我得到的錯誤:Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in.... on line ..
MySQL數字行在if語句中發出警告?
請你能告訴我我做錯了什麼導致這個。我不相信我是。
if (mysql_num_rows(mysql_query("SELECT * FROM Likes WHERE `postID` = '$postID' AND `userID` = '$accountID'")) < 1) {
exit("Cant like a post twice");
}
mysql_query返回布爾值如果查詢因任何原因導致錯誤,則返回布爾值。將結果傳遞給mysql_num_rows將導致此錯誤,因爲num_rows需要一個語句句柄,但會得到錯誤條件FALSE。 – 2011-06-05 23:40:06