search

Home  >  Q&A  >  body text

What's the reason for reporting an error?

 Fatal error: Call to a member function query() on a non-object in E:\WWW\mvc\model\Db.php on line 70

好想睡懒觉、好想睡懒觉、2469 days ago1463

reply all(3)I'll reply

  • Don't cry

    Don't cry2018-02-27 18:15:53

    There may be something wrong with the way you call the database. Check your code and read the documentation

    reply
    0
  • 韦小宝

    韦小宝2018-02-26 13:34:12

    Post the code and have a look

    reply
    0
  • 好想睡懒觉、

    private function connect() { try{ //Configure data source DSN $dsn = "{$this->dbConfig['db']}:host={$this->dbConfig['host']}; port={$this->dbConfig['port']};dbname={$this->dbConfig['dbname']}; charset={$this->dbConfig['charset']}"; //Create PDO object new PDO($dsn,$this->dbConfig['user'],$this->dbConfig['pass']); //Set the client's default character set $this->conn->query("SET NAMES {$this->dbConfig['charset']}"); //Here is line 70 }catch (PDOException $e){ die('Database connection failed'.$e->getMessage()); } }

    好想睡懒觉、 · 2018-02-27 09:23:35
  • Cancelreply