因此,出于某些原因,当我在准备好的语句中使用= operater时,没有问题,但是当我使用下面的运算符(<)时,它会出错。
mysqli_fetch_assoc()期望参数1为mysqli_result,给定布尔值。
所以我知道如果我的查询有问题,mysql会给出错误。但我无法看到问题。
function availableapps($security)
{
if(empty($databasemanager)) { $databasemanager = new databasemanager(); }
$db = $databasemanager->connectionstring();
$result = $db->prepare("SELECT name FROM applications Where security<?");
$result->bind_param("s", $security);
$result->execute();
$types = array();
while(($row = mysqli_fetch_assoc($result->get_result()))) {
$types[] = $row['name'];
}
$result->close();
return $types;
}
仅供演示之用, 最终工作代码:
function availableapps($security)
{
if(empty($databasemanager)) { $databasemanager = new databasemanager(); }
$db = $databasemanager->connectionstring();
$result = $db->prepare("SELECT name FROM applications Where security<?");
$result->bind_param("s", $security);
$result->execute();
$results = $result->get_result();
$types = array();
while($row = $results->fetch_assoc()) {
$types[] = $row['name'];
}
$result->close();
return $types;
}
答案 0 :(得分:1)
while ($row = $result->fetch_assoc()) {