<?php
// Forum Configuration
define('DB_HOST','localhost'); // Database Hostname
define('DB_USER','root'); // Database Username
define('DB_PASSWORD',''); // Database Password
define('DB_NAME','ultraforum'); // Database Name
define('WEB_NAME','Website Name'); // Website Name
define('WEB_TITLE','Website Title'); // Website Title
// Do not modify anything under this line :)
class db {
var $dbhost;
var $dbuser;
var $dbpassword;
var $dbname;
var $query;
function connect() {
$this->db =
new mysqli($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname);
}
function __construct() {
$this->dbhost = DB_HOST;
$this->dbuser = DB_USER;
$this->dbpassword = DB_PASSWORD;
$this->dbname = DB_NAME;
}
}
And my Forum class extending DB
class forum extends db{
public function __construct() {
parent::__construct();
}
function displayInfo () {
$this->forumInfo =
$getInfo = $db->db->query("SELECT * FROM threads");
while($getI = $getInfo->fetch_object()) {
return $getI->Title;
}
}
}
With the second class, I want to get all of the threads from my mysqli database. I extended it from the first class because I wanted the connection information. This is how im implementing the class:
$ThreadInfo = new forum;
$ThreadInfo->displayInfo();
But I get
Notice: Undefined property: forum::$db on line 42
Fatal error: Call to a member function query() on a non-object in on line 42