开发者

Fatal error: Call to undefined method mysqli_stmt::fetch_array() [duplicate]

This question already has answers here: Call to undefined method mys开发者_开发问答qli_result::fetch() (2 answers) Closed 1 year ago.

in this code i get the error: Fatal error: Call to undefined method mysqli_stmt::fetch_array()

What is the problem?

$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();

thanks


Using prepared statements there is no fetch_array(). Use mysqli_stmt::fetch() instead or to fetch multiple records use mysqli_result::fetch_all()
Check the manual: mysqli_stmt::fetch() or mysqli_result::fetch_all()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜