致命错误:未捕获错误:在null()上调用成员函数query()

时间:2018-08-08 23:11:53

标签: php html mysqli

Database.php

// selecting query
     public function select($query){

         And here-> $result = $mysqli->query($query);

        if($result->num_rows > 0){
            return $result;
        }

        else{
            return false;
        }

Header.php

<?php

    include 'libraries/config.php';

include 'libraries/database.php';

//creating new object of database
$db = new database();

$query = "select * from posts order by id desc";

giving error here -> $posts = $db->select($query);

?>
  

致命错误:未捕获错误:在C:\ xampp \ htdocs \ OOP \ libraries \ database.php:40中对成员函数query()的调用为null:堆栈跟踪:#0 C:\ xampp \ htdocs \ OOP \ include \ header.php(11):database-> select('select * from p ...')#1 C:\ xampp \ htdocs \ OOP \ index.php(3):include('C:\ xampp \ htdocs ...')#2 {main}在第40行的C:\ xampp \ htdocs \ OOP \ libraries \ database.php中抛出

0 个答案:

没有答案