开发者

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

开发者 https://www.devze.com 2023-02-24 06:22 出处:网络
This question already has answers here: Call to undefined method mys开发者_开发问答qli_result::fetch()
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

精彩评论

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

关注公众号