[PHP] Class Error

Status
Not open for further replies.

brsy

nah mang
May 12, 2011
1,530
272
Okay, so this was working earlier, but it just seemed to stop working. Here is the codes and the error:

class.engine.php
PHP:
    public function onlineUsers() {
    return mysql_result(mysql_query("SELECT users_online FROM server_status LIMIT 1"), 0);
    }

class.tpl.php
PHP:
        public function __construct() {
       
                global $users, $db, $config, $engine;
                $this->setParam("hotelName", $config['hotel']['name']);
                $this->setParam("url", $config['hotel']['url']);
                $this->setParam("skin", $config['hotel']['skin']);
                $this->setParam('build', $config['server']['build']);
               
                $this->setParam('facebook', '393566863990169');
               
                $this->setParam('online', $engine->onlineUsers());
               
        }

Error
Fatal error: Call to a member function onlineUsers() on a non-object in C:\xampp\htdocs\class\class.tpl.php on line 34

Line 34 is the line where I setParam('online', $engine->onlineUsers());

 

brsy

nah mang
May 12, 2011
1,530
272
Your doing it wrong, your calling the classTPL from the global? It seems your not calling the engine class.
I called everything in the global.
PHP:
<?php
 
/*
*
*  Initiating the required files
*
*/
 
require_once("class/class.configuration.php");
require_once("class/class.tpl.php");
require_once("class/class.engine.php");
 
/*
*
*  Defining the class' as variables
*
*/
 
$tpl = new tpl();
$engine = new engine();
 
?>
 
Status
Not open for further replies.

Users who are viewing this thread

Top