Mysqli::query(): 数据库连接错误
“mysqli::query(): 无法获取 mysqli”错误通常表明数据库连接有问题。以下步骤描述了该问题并根据提供的代码片段提供了解决方案:
解决方案:
修改后的代码:
// Connection file $DBConnect = new mysqli("localhost", "root@localhost", NULL, "Ladle"); // Check for connection error if ($DBConnect->connect_errno) { $ErrorMsgs[] = "The database server is not available. Connect Error is " . $DBConnect->connect_errno . " " . $DBConnect->connect_error . "."; } // Class class EventCalendar { private $DBConnect = NULL; function __construct() { include("inc_LadleDB.php"); $this->DBConnect = $DBConnect; } function __destruct() { // Close the connection only if it's not closed already if (!$this->DBConnect->connect_error) { $this->DBConnect->close(); } } function __wakeup() { // Include the database connection data include("inc_LadleDB.php"); $this->DBConnect = $DBConnect; } // Event adding method // ... }
以上是为什么我的 mysqli::query() 失败并出现'无法获取 mysqli”数据库连接错误?的详细内容。更多信息请关注PHP中文网其他相关文章!