对boolean调用成员函数prepare()



我今天启动了wamp来检查我的一个网站,并遇到了一个php错误

[30-Jan-2022 16:57:28 UTC] PHP Fatal error:  Uncaught Error: Call to a member function prepare() on boolean in C:wamp64wwwincludesclass.database.php:130
Stack trace:

当检查有问题的php文件时,我不知道如何解决这个问题,有人可以帮忙吗?

// Allow for prepared arguments. Example:
// query("SELECT * FROM table WHERE id = :id", array('id' => $some_val));
$sth = $this->db->prepare($sql);
$debugSql = $sql;
$params = array();
if (is_array($args_to_prepare))
{
foreach ($args_to_prepare AS $name => $val)
{
$params[':' . $name] = $val;
$debugSql = preg_replace('/:'.$name.'/',"'".$val."'", $debugSql);
}
}

重用函数的最佳方法是将其放入include文件中,然后将其包含在需要的每个文件的顶部。因此,在db_connection.php中,创建函数:

点击此

最新更新