因此我尝试创建一个下拉菜单,其中包含数据库中所有已验证但不是admin的用户(这两个都是数据库中的列),并从“Owner”列中获取用户名,并将每个用户放在下拉菜单中。我收到错误警告:mysqli_result :: fetch_assoc()预计正好0个参数,第47行/home/content/96/10688096/html/testserver/requestpage.php中给出的参数
session_start();
if($_SESSION['admin']=='y') {
?>
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="Scripts/request.js"></script>
<link rel='stylesheet' href='CSS/requestpage.css'>
<title> Admin Page </title>
</head>
<body>
<!-- Header Divs -->
<div id='header'>
<div id='title'>
<!-- Header Text -->
</div>
</div>
<div id='sidebar'>
<?php
$username = $_SESSION['id'];
$usernamelc = strtolower($username);
$userimage = "<img src='images/$usernamelc.png'> ";
$adminid = $_SESSION['recid'];
include('connection.php');
$sidebar = "<div id='sidebar'> <table id='admininfo'> <tr> <td colspan='2'> $userimage</td> </tr>
<tr> <td colspan='2'> <span> Welcome, $username </span> </td> </tr> <tr> <td> Admin: </td> <td> $username </td> </tr>
<tr> <td> ID: </td> <td> $adminid </td> </tr> <tr> <td> Number of Users: </td> <td> {$users} </td> </tr> <tr> <td colspan='2'> <span> Emulator </span> </td> </tr>
<select>";
$users = $db->query("SELECT Owner FROM users WHERE verified = 'y' AND admin ='n'");
while ($row = $users->fetch_array($users)) {
$sidebar .= "<option value='{$row['Owner']}'> </option>";
}
$sidebar .= "</select> </td> </tr> </table> </div>";
echo $sidebar;
?>
</div>
<?php
}
?>
答案 0 :(得分:3)
阅读您的错误。
while ($row = $users->fetch_array($users)) {
需要成为
while ($row = $users->fetch_array()) {