Fatal error: Call to undefined method mysqli_stmt::fetch_array() [duplicate]
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()
精彩评论