<?php
require "conn.php";
$GroupName = "test";
$sql_query ="SELECT G_number FROM Group WHERE Group_Name like '$GroupName';";
$row = mysqli_query($conn,$sql_query);
$result = $row->get_result(); //error comes up here
$sql_query2 =$conn->prepare("SELECT Question, User_name,date FROM Post WHERE Group_number = '$result';");
$sql_query2->execute();
$sql_query2->bind_result($Question,$User_name,$date);
$post = array();
while($sql_query2->fetch()){
$temp = array();
$temp['Question'] = $Question;
$temp['User_Name'] = $User_name;
$temp['Date'] = $date;
array_push($post,$temp);
}
echo json_encode($post);
?>
当我将域放入url时,我试图将json打印到html,但是我的日志中不断出现此错误:
“ PHP致命错误:未捕获错误:调用成员函数 布尔值中的get_result() /home/f7215owv4qzh/public_html/post_retrieval.php:8“
有人知道我在做什么错吗?我已经搜索了修复程序,并将语法更改为无效。
答案 0 :(得分:0)
尝试这种方式
$result = $row->fetch_array();
OR
$result =mysqli_fetch_array($row)