所以我得到了错误:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\All Connected\profile.php on line 117
在尝试检查朋友请求状态信息时,我看到有人使用MySQL错误转储修复此问题或类似但我不确定,我可以获得一些帮助吗?
这是我的代码的片段,只有需要修复的部分
mysql_connect("illuzionz-pc", "-----", "----------");
mysql_select_db("allcon");
$my_id = $_SESSION['user_id'];
$profile_id = $_GET['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 "<br><a class='pure-button pure-button-disabled' href='#'>Already Friends!</a><br>";
echo "<a class='button-error pure-button' href='#'>Unfriend {$user['first_name']}</a>";
} else {
mysql_connect("illuzionz-pc", "Admin", "0A562B0CA0");
mysql_select_db("allcon");
$my_id = $_SESSION['user_id'];
$profile_id = $_GET['id'];
$from_query = mysql_query("SELECT `id` FROM `friend_req` WHERE `from`='$profile_id' AND `to`='$my_id'");
$to_query = mysql_query("SELECT `id` FROM `friend_req` WHERE `from`='$my_id' AND `to='$profile_id'");
if(mysql_num_rows($from_query) == 1){
echo "<a class='button-secondary pure-button' href='#'>Ignore Friend Request</a><br>";
echo "<a class='button-success pure-button' href='#'>Accept Friend Request</a>";
} else if(mysql_num_rows($to_query) == 1){
echo "<a class='button-error pure-button' href='#'>Cancel Friend Request</a>";
} else {
echo "<a class='pure-button pure-button-primary' href='#'>Send Friend Request</a>";
}
}
答案 0 :(得分:3)
您的Option Strict On
已经返回mysql_query
,因为您传递了无效的SQL。
将$ to_query修复为:
false