我试图设置一个系统,如果你正在看你自己的个人资料,你不能自己朋友,如果你在另一个人的个人资料,你可以。问题是我得到这个错误。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