Call to a member function on a non-object
Posted: Fri Jun 30, 2006 5:50 pm
Error: Call to a member function on a non-object
I keep getting the error above on the line marked below (not the actual code, obviously). I have been using an '&' with the database object when making objects. It works until I get to the line marked below as 'problem line'. I don't understand the '&'. Please tell me what I'm doing wrong. Thanks.
My code is like this...
I keep getting the error above on the line marked below (not the actual code, obviously). I have been using an '&' with the database object when making objects. It works until I get to the line marked below as 'problem line'. I don't understand the '&'. Please tell me what I'm doing wrong. Thanks.
My code is like this...
Code: Select all
$db = new Database;
$mod = new Module(&$db);
class Module {
var $db;
function Module(&$db) {
$this->db = &$db;
}
function make_objects() {
$obj = new Object(&$db);
}
}
class Object {
var $db;
function Object(&$db) {
$this->db = &$db;
}
function do_query($query) {
$this->db->query($query); // problem line
}
}