【问题标题】:Uncaught Error: Call to a member function get_result() on boolean未捕获的错误:在布尔值上调用成员函数 get_result()
【发布时间】: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


    【解决方案1】:

    试试这个方法

    $result = $row->fetch_array();
    

    $result =mysqli_fetch_array($row) 
    

    【讨论】:

    • 替换第8行,放在前面还是后面?
    猜你喜欢
    • 2017-05-03
    • 1970-01-01
    • 2020-07-29
    • 2019-12-23
    • 1970-01-01
    • 1970-01-01
    • 2015-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多