姬長信(Redy)

php – 致命错误:调用未定义的方法mysqli_…


在这段代码中我得到错误:致命错误:调用未定义的方法mysqli_stmt :: fetch_array()

问题是什么?

$search= "player";

($sql = $db->prepare('select job from jobs where job like ?'));

$sql->bind_param('s', $search);
$sql->execute();
$sql->bind_result($search);

$data = array();

while ($sql->fetch_array(MYSQLI_ASSOC)) {
    $data[] = array(
            'label' => $row['job']  
    );
    echo json_encode($data);

}

$sql -> close();
$db -> close();

谢谢