Call to undefined method
Posted: Sat Oct 13, 2012 11:56 am
I have two classes, one is my db.class.php which contains all of my sql functions.
When i instaniate the class with $db instead doing it over and over and over i want to pass the object into the new class.
$db = new mysql()
$account = new account($db)
So i pass $db into the class account which looks like this..
But when i call ->query which is a method inside of the db.class.php (and works when i don't pass the object into a new class) the error message i get is
PHP Fatal error: Call to a member function query() on a non-object in account.class.php on line 9
Any thouhts?
Thanks,
Anthony
When i instaniate the class with $db instead doing it over and over and over i want to pass the object into the new class.
$db = new mysql()
$account = new account($db)
So i pass $db into the class account which looks like this..
Code: Select all
function account($db) {
$this->db = $db;
var_dump($this->db); //This actually displays the correct information and class_exists verifies the class does exist
}
function resetPassword($email) {
$sql = $this->db->query("select * from users");
}
}
PHP Fatal error: Call to a member function query() on a non-object in account.class.php on line 9
Any thouhts?
Thanks,
Anthony