致命错误:未捕获的错误:在布尔值in中调用成员函数fetch_all()

问题描述 投票:0回答:1

我有一个完整的PHP项目,可以在我的本地主机上正常运行,我已经将其上传https://www.000webhost.com/,但是当我尝试运行它时,它抛出了一个错误,我已经多次检查了所有配置,并且一切都在其适当的位置,我我不确定为什么会收到此错误。这是我得到的错误:

Fatal error: Uncaught Error: Call to a member function fetch_all() on boolean in 
/storage/ssd3/684/12771684/public_html/app/database/db.php:58 Stack trace: #0 
/storage/ssd3/684/12771684/public_html/app/database/db.php(178): selectAll('article_all_det...', 
Array) #1 /storage/ssd3/684/12771684/public_html/index.php(3): include('/storage/ssd3/6...') #2 
{main} thrown in /storage/ssd3/684/12771684/public_html/app/database/db.php on line 58
php mysql database hosting
1个回答
0
投票

这是全选功能:

function selectAll($table, $conditions,$order=null)
 {
global $conn;
$sql = "SELECT * FROM $table";
if (empty($conditions)) {
    // return all records without condition
    $stmt = $conn->prepare($sql);
    $stmt->execute();
    $records = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
    return $records;
} else {
    // return records that mathces condition
    $i = 0;
    foreach ($conditions as $key => $value) {
        if ($i == 0) {
            $sql = $sql . " WHERE $key=?";
        } else {
            $sql = $sql . " AND $key=?";
        }
        $i++;
    }
    if($order!=null){
        $sql.=" order by ".$order;
    }
    $stmt = executeQuery($sql, $conditions);
    $records = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
    return $records;
     }
  }
© www.soinside.com 2019 - 2024. All rights reserved.