$hasil=mysqli_query($connect, $ambil);
$hasil_id=$hasil['id'];
$hasil_name=$hasil['name'];
$hasil_email=$hasil['email'];
$hasil_comment=$hasil['comment'];
我从上面的代码中得到了这个致命错误,是否与php版本有关?特别是在使用mysqli时
答案 0 :(得分:1)
使用mysqli_fetch_assoc或mysqli_fetch_array将结果行作为关联数组获取。
query = "SELECT 1";
$ result = $ mysqli-> query($ query); $ followingdata = $ result-> fetch_assoc()
答案 1 :(得分:0)
编辑如下。您正在尝试将mysqli结果用作数组。
$hasil=mysqli_query($connect, $ambil);
//Assuming you're expecting a single result
$hasil = mysqli_fetch_array($hasil); //Create array from first result
$hasil_id=$hasil['id'];
$hasil_name=$hasil['name'];
$hasil_email=$hasil['email'];
$hasil_comment=$hasil['comment'];