【发布时间】:2018-11-30 04:38:00
【问题描述】:
<?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() on boolean in /home/f7215owv4qzh/public_html/post_retrieval.php:8"
有人知道我做错了什么吗?我已经搜索了修复程序并将语法更改为无济于事。
【问题讨论】:
标签: php