Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP系统错误_Php_Mysql - Fatal编程技术网

PHP系统错误

PHP系统错误,php,mysql,Php,Mysql,我正在尝试建立一个系统,如果你正在查看自己的个人资料,你不能成为自己的朋友,如果你在另一个人的个人资料上,你可以。问题是我得到了这个错误 警告:mysql_num_rows()希望参数1是资源,字符串在第60行的C:\xampp\htdocs\profile.php中给出 if($user['id')!=$my\u id){ mysql_connect('localhost','root',''); mysql_选择_数据库(“所有连接”); $profile_id=$user['id']; $

我正在尝试建立一个系统,如果你正在查看自己的个人资料,你不能成为自己的朋友,如果你在另一个人的个人资料上,你可以。问题是我得到了这个错误

警告:mysql_num_rows()希望参数1是资源,字符串在第60行的C:\xampp\htdocs\profile.php中给出

if($user['id')!=$my\u id){
mysql_connect('localhost','root','');
mysql_选择_数据库(“所有连接”);
$profile_id=$user['id'];
$check_-friend_-query=mysql_-query(“从朋友中选择id,其中(用户_-one='$my_-id'和用户_-two='$profile_-id')或(用户_-one='$profile_-id'和用户_-two='$my_-id');
if(mysql\u num\u rows($check\u friend\u query)==1){
回声“;
}否则{
回声“;
}
}
$con=mysql\u connect('localhost','root','');
mysql_select_db('All Connected',$con);
如果($user['id']!=$my_id){
$profile_id=$user['id'];
echo“从朋友中选择id,其中用户_-one='$my-id'和用户_-two='$profile-id')或(用户_-one='$profile-id'和用户_-two='$my-id');
$check_-friend_-query=mysql_-query(“从朋友中选择id,其中用户_-one='$my_-id'和用户_-two='$profile_-id')或(用户_-one='$profile_-id'和用户_-two='$my_-id');
if(mysql\u num\u rows($check\u friend\u query)>0){
回声“;
}否则{
回声“;
}

请,。它们不再被维护,现在是。改为了解,然后使用。错误是不言自明的,查询不起作用。您需要添加一些错误检查。另外,请停止在每个单词上使用大写字母,这会使您的文本难以阅读。还请注意错误消息与此代码一样没有意义。请仔细检查。最有可能的情况是,您应该查看解释您所做的更改以及更改原因。您在使用此功能后是否再次出现错误…………仍然会收到警告:mysql_num_rows()期望参数1是资源,布尔值在C:\xampp\htdocs\profile.php中给出,在第62行对不起,$my_id这个变量值在u声明的地方,您的未声明的na…它被声明了,只是不在这里$my_id=$\u SESSION['user_id'];
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>";
    }
}
$con = mysql_connect('localhost', 'root', '');
mysql_select_db('All Connected',$con);

if($user['id'] != $my_id){

       $profile_id = $user['id'];

echo "SELECT id FROM friends WHERE user_one='$my_id' AND user_two='$profile_id') OR (user_one='$profile_id' AND user_two='$my_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)>0) {

echo "<a href='#' class='box'>You Are Already Friends!</a>";

 } else {

 echo "<a href='#' class='box'>Send Friend Request!</a>";
               }