我有一个完整的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
这是全选功能:
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;
}
}