【问题标题】:PHP Fatal error: Call to undefined method mysqli_stmt::get_result() on Godaddy host [duplicate]PHP致命错误:调用Godaddy主机上未定义的方法mysqli_stmt::get_result() [重复]
【发布时间】:2018-01-05 06:10:17
【问题描述】:

我正在编写一些代码来使用准备好的语句获取数据。下面是我的代码

$statement = $connection->prepare("select * from products where id =?");
$statement->bind_param('d',$id);
$statement->execute();
$result = $statement->get_result();
$product_details = $result->fetch_all();

我正在使用PHP 5.6。这在我的localhost 上运行良好,没有错误。当我将此文件上传到我的 Godaddy 主机时,会出现错误:

PHP 致命错误:调用未定义的方法 mysqli_stmt::get_result()

我在互联网上搜索,但没有找到满意的结果,在 stackoverflow 上我发现了几个类似的问题,但没有找到适合我的解决方案。 在 Godddy 主机上,我启用了 mysqld 扩展并运行 PHP 5.6 所以任何帮助

【问题讨论】:

    标签: php mysql mysqli


    【解决方案1】:

    您的 $statement->execute() 可能存在问题。尝试在 try catch 块中运行此代码,可能会发现一些异常。或使用 if 块运行此方法。

    if($statement){
        $result = $statement->get_result();
    } 
    

    try{
       $statement = $connection->prepare("select * from products where id =?");
       $statement->bind_param('d',$id);
       $statement->execute();
       if($statement){
         $result = $statement->get_result();
       } 
       $product_details = $result->fetch_all(); 
    } catch (Exception $e) {
       echo 'Caught exception: ',  $e->getMessage(), "\n";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-02
      • 2014-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-05
      相关资源
      最近更新 更多