I want to call a PHP class in another class and get the following error:
Fatal error: Call to a member function quote() on a non-object
Class 1:
class logmein {
//Connect DB
function dbconnect(){
require_once('class.MySQL.php');
$db = new Db();
}
//login function
function login($username, $password){
//conect to DB
$this->dbconnect();
// Quote and escape form submitted values
$name = $db -> quote($username); //throwing error
$email = $db -> quote($password); //throwing error
}
}
Class 2:
class DB {
public function quote($value) {
$connection = $this -> connect();
return "'" . $connection -> real_escape_string($value) . "'";
}
}
I call it:
$log = new logmein();
$log->login('James Bond', '007');
What I have to do to call them into each other? Or is there a other way to do that. Thanks a lot for help!