gpt4 book ai didi

php - mysql_num_rows() 期望参数 1 为资源, bool 值

转载 作者:行者123 更新时间:2023-11-30 23:00:39 25 4
gpt4 key购买 nike

<分区>

我一直收到这个错误:

mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/u592632722/public_html/profile.php on line 80

我不知道如何解决它。这是我的 profile.php 代码:

 <?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
$userid = $_SESSION['userid'];
$name = $_SESSION['name'];
$username = $_SESSION['username'];
$user = $_GET['user'];
$title = "$user";
?>
<?php
$user = $_GET['user'];

require("./connect.php");

$query = mysql_query("SELECT * FROM user WHERE username='$user'");
$numrows = mysql_num_rows($query);
echo $numrows;
if ($numrows == 1){
$title = "$user";
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$user = $row['username'];
$dbname = $row['name'];
$dbactive = $row['active'];
$dbdate = $row['date'];
echo "<h1 align='center'>$user's profile page</h1>";
if($dbactive == 1){
$active = "yes";
}
else{
$active = "no";
}
if ($userid && $username){
$query = mysql_query("SELECT * FROM friends WHERE (user_one='$user' and user_two='$username') or (user_one='$username' and user_two='$user')");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
echo "
<center>
<table style='border:2px solid black; font-size:36px;' bgcolor='red'>
<ul>
<tr>
<td style='border:1px solid black;'>name:</td>
<td style='border:1px solid black;'>$dbname</td>
</tr>
<tr>
<td style='border:1px solid black;'>username:</td>
<td style='border:1px solid black;'>$user</td>
</tr>
<tr>
<td style='border:1px solid black;'>frends:</td>
<td style='border:1px solid black;'>yes</td>
</tr>
<tr>
<td style='border:1px solid black;'>date joined:</td>
<td style='border:1px solid black;'>$dbdate</td>
</tr>
<tr>
<td style='border:1px solid black;'>activated:</td>
<td style='border:1px solid black;'>$active</td>
</tr>
</ul>
</table>
</center>";
}
else{
$query = mysql_query("SELECT id FROM friend_req WHERE from='1' and to='1'");
echo "Mysql query: $query";
echo "</br>";
$numromws = mysql_num_rows($query);
echo "Mysql numrows: $numrows";
if ($numromws == "1"){
echo "
<center>
<table style='border:2px solid black; font-size:36px;' bgcolor='red'>
<ul>
<tr>
<tr>
<td style='border:1px solid black;'>name:</td>
<td style='border:1px solid black;'>$dbname</td>
</tr>
<tr>
<td style='border:1px solid black;'>username:</td>
<td style='border:1px solid black;'>$user</td>
</tr>
<tr>
<td style='border:1px solid black;'>friends:</td>
<td style='border:1px solid black;'>waiting for friend request confirmation</td>
</tr>
<tr>
<td style='border:1px solid black;'>date joined:</td>
<td style='border:1px solid black;'>$dbdate</td>
</tr>
<tr>
<td style='border:1px solid black;'>activated:</td>
<td style='border:1px solid black;'>$active</td>
</tr>
</ul>
</table>
</center>";
}
else{
$query = mysql_query("SELECT * FROM friend_req WHERE 'from'='$user' AND 'to'='$username'");
$numromws = mysql_num_rows($query);
if ($numromws == "1"){
echo "
<center>
<table style='border:2px solid black; font-size:36px;' bgcolor='red'>
<ul>
<tr>
<tr>
<td style='border:1px solid black;'>name:</td>
<td style='border:1px solid black;'>$dbname</td>
</tr>
<tr>
<td style='border:1px solid black;'>username:</td>
<td style='border:1px solid black;'>$user</td>
</tr>
<tr>
<td style='border:1px solid black;'>frends:</td>
<td style='border:1px solid black;'><form method='post' action='./$user'><input type='submit' name='acceptfriendreq' value='accept friend request' /></form></td>
</tr>
<tr>
<td style='border:1px solid black;'>date joined:</td>
<td style='border:1px solid black;'>$dbdate</td>
</tr>
<tr>
<td style='border:1px solid black;'>activated:</td>
<td style='border:1px solid black;'>$active</td>
</tr>
</ul>
</table>
</center>";

}
else{
echo "
<center>
<table style='border:2px solid black; font-size:36px;' bgcolor='red'>
<ul>
<tr>
<td style='border:1px solid black;'>name:</td>
<td style='border:1px solid black;'>$dbname</td>
</tr>
<tr>
<td style='border:1px solid black;'>username:</td>
<td style='border:1px solid black;'>$user</td>
</tr>
<tr>
<td style='border:1px solid black;'>frends:</td>
<td style='border:1px solid black;'><form method='post' action='./$user'><input type='submit' name='friendcreate' value='send friend request' /></form></td>
</tr>
<tr>
<td style='border:1px solid black;'>date joined:</td>
<td style='border:1px solid black;'>$dbdate</td>
</tr>
<tr>
<td style='border:1px solid black;'>activated:</td>
<td style='border:1px solid black;'>$active</td>
</tr>
</ul>
</table>
</center>";
}
}
}
}
else{
echo "
<center>
<table style='border:2px solid black; font-size:36px;' bgcolor='red'>
<ul>
<tr>
<td style='border:1px solid black;'>name:</td>
<td style='border:1px solid black;'>$dbname</td>
</tr>
<tr>
<td style='border:1px solid black;'>username:</td>
<td style='border:1px solid black;'>$user</td>
</tr>
<tr>
<td style='border:1px solid black;'>date joined:</td>
<td style='border:1px solid black;'>$dbdate</td>
</tr>
<tr>
<td style='border:1px solid black;'>activated:</td>
<td style='border:1px solid black;'>$active</td>
</tr>
</ul>
</table>
</center>";
}
}
elseif ($user == ""){
$title = "profile page";
echo "<h1 align='center'>Profile page</h1>";
if($userid && $username){
echo "<h1 align='center'>my profile</h1>";
$query = mysql_query("SELECT * FROM user WHERE username='$username'");
$title = "$username";
$row = mysql_fetch_assoc($query);
$dbid = $row['id'];
$dbname = $row['name'];
$dbactive = $row['active'];
$dbdate = $row['date'];
if($dbactive == 1){
$active = "yes";
}
else{
$active = "no";
}
echo "
<center>
<table style='border:2px solid black; font-size:36px;' bgcolor='red'>
<ul>
<tr>
<td style='border:1px solid black;'>name:</td>
<td style='border:1px solid black;'>$dbname</td>
</tr>
<tr>
<td style='border:1px solid black;'>username:</td>
<td style='border:1px solid black;'>$username</td>
</tr>
<tr>
<td style='border:1px solid black;'>date joined:</td>
<td style='border:1px solid black;'>$dbdate</td>
</tr>
<tr>
<td style='border:1px solid black;'>activated:</td>
<td style='border:1px solid black;'>$active</td>
</tr>
</ul>
</table>
</center>";
}
}
else {
$title = "profile page";
echo "<h1 align='center'>the user does not exsist</h1>";
}
mysql_close();
?>

这是我的connect.php

<?php

mysql_connect("mysql.freehostingnoads.net", "u592632722_mat", "password");
mysql_select_db("u592632722_info");

?>

密码已替换为我的实际密码。请帮忙!

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