gpt4 book ai didi

php - MySQL Numrows 期望参数

转载 作者:太空宇宙 更新时间:2023-11-03 11:54:10 26 4
gpt4 key购买 nike

所以我得到了错误:

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>";
}
}

最佳答案

您的 mysql_query 返回了 false,因为您向它传递了无效的 SQL。将您的 $to_query 修复为:

$to_query = mysql_query("SELECT `id` FROM `friend_req` WHERE `from`='$my_id' AND `to`='$profile_id'");

关于php - MySQL Numrows 期望参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33953701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com