开发者社区> 问答> 正文

mysqli :: query():无法获取mysqli

警告:mysqli :: query():无法在第43行上的C:\ Program Files(x86)\ EasyPHP-DevServer-13.1VC9 \ data \ localweb \ my Portable files \ class_EventCalendar.php中获取mysqli

以下是我的连接文件:

connect_errno) { // Add error to errors array $ErrorMsgs[]="The database server is not available.". " Connect Error is ".$DBConnect->connect_errno." ". $DBConnect->connect_error."."; } ?> 这是我的课: DBConnect = $DBConnect; } function __destruct() { if (!$this->DBConnect->connect_error) { $this->DBConnect->close(); } } function __wakeup() { // Include the database connection data include("inc_LadleDB.php"); $this->DBConnect = $DBConnect; } // Function to add events to Zodiac calendar public function addEvent($Date, $Title, $Description) { // Check to see if the required fields of Date and Title have been entered if ((!empty($Date)) && (!empty($Title))) { /* if all fields are complete then they are inserted into the Zodiac event_calendar table */ $SQLString = "INSERT INTO tblSignUps". " (EventDate, Title, Description) ". " VALUES('$Date', '$Title', '". $Description."')"; // Store query results in a variable $QueryResult = $this->DBConnect->query($SQLString); 我对OOP PHP不太满意,而且不确定为什么会引发此错误。我从其他地方提取了此代码,唯一更改的是@new mysqli参数。谁能帮助我了解问题出在哪里?

展开
收起
保持可爱mmm 2020-05-11 10:55:24 406 0
1 条回答
写回答
取消 提交回答
  • 可能是您在某个地方DBconnection->close();,然后尝试执行某些查询。

    提示:它有时错误插入...->close();的__destruct()(因为__destruct是大事,在这之后会有需要查询的执行)来源:stack overflow

    2020-05-11 10:56:08
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载