HI,..i've been working on this simple project that i need to submit it tomorrow.
I really in rushing a little bit.
But while i working on this oop project, my program give the strange little fatal error about my query which is this
Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\listnote\index.php on line 25
I really sure that i wrote everything down correctly already, so that i really dont understand why did this error appear :(
Below here are the code :
This is my database class which i name it db.php
?php
//my database class
class Db {
// make sure we dont connnect database to every function
public $mysql;
function __contruct(){
$this->mysql = new mysqli('localhost','root','password','db') or die ("problem");
}
?>
and here is my main program, index.php
<div id="todo">
<?php
require 'db.php';
$db = new Db();
$query = "SELECT*FROM list";
$results = $mysql->query($query);
if($results->num_rows){
while($row = $results->fetch_object()) {
$title = $row->title;
$description = $row->description;
$id = $row->id;
//the rest of the code go here
}
?>
</div>
could anyone figure it out for me?i really desperate right now as i could not continue my work because of this just small error.
Thanks in advance.