我试图根据3个要求选择我的帖子表中的所有行。
来自帖子表的用户标识=来自用户表的用户标识
来自帖子表的主机ID =来自用户表的用户ID
帖子表中的commentid =零
我想选择满足这些要求的所有行。这是错误...
Fatal error: Uncaught Error: Call to a member function fetch_assoc() on bool in C:\xampp\htdocs\loginsystem\includes\posts.inc.php:108 Stack trace: #0 C:\xampp\htdocs\loginsystem\home.php(38): getUploads(Object(mysqli)) #1 {main} thrown in C:\xampp\htdocs\loginsystem\includes\posts.inc.php on line 108
这是我的代码...
function getUploads($conn) {
$userName = $_GET["user"];
$sqluserid = "SELECT userid FROM users WHERE userName = $userName";
$userid = mysqli_query($conn, $sqluserid);
$sqlusercontent = "SELECT * FROM posts WHERE hostid = $userid AND userid = $userid AND commentid = 0";
$usercontent = mysqli_query($conn, $sqlusercontent);
$postid = 1;
// This is the actual upload content
while ($row = $usercontent->fetch_assoc()) {
echo "<div class='postbox'><p>";
echo $row['title']."<br>";
echo $row['date']."<br>";
echo "<div><img src='posts/".$userid."/".$postid.".*></div>";
echo $row['description']."<br>";
echo "</p>";
echo "</div>";
$postid++;
}
}
小唯快跑啊