我試圖設置一個系統,如果你正在看你自己的個人資料,你不能自己朋友,如果你在另一個人的個人資料,你可以。問題是我得到這個錯誤。PHP朋友你自己系統錯誤
警告:mysql_num_rows()預計參數1是資源,在串C中給出:\ XAMPP \ htdocs中\ profile.php線60上
if($user['id'] != $my_id) {
mysql_connect('localhost', 'root', '');
mysql_select_db('All Connected');
$profile_id = $user['id'];
$check_friend_query = mysql_query("SELECT id FROM friends WHERE (user_one='$my_id' AND user_two='$profile_id') OR (user_one='$profile_id' AND user_two='$my_id')");
if(mysql_num_rows($check_friend_query) == 1){
echo "<a href='#' class='box'>You Are Already Friends!</a>";
} else {
echo "<a href='#' class='box'>Send Friend Request!</a>";
}
}
請,[停止使用'mysql_ *'函數](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php)。他們不再被維護,並[正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。瞭解[準備的陳述](http://en.wikipedia.org/wiki/Prepared_statement),並使用[PDO](http://jayblanchard.net/demystifying_php_pdo.html)。該錯誤非常明顯,查詢無效。你需要添加一些錯誤檢查。 –
也請停止使用每個單詞上的大寫字母,這會讓您的文本難以閱讀。 –
另請參閱http://www.phptherightway.com/#mysql_extension – contrebis