I've run into a little problem implementing classes and accessing properties throughout them. Let me illustrate:
Code: Select all
require('../lib/class.Validate.php');
require('../lib/class.MySQL.php');
class UserProfile {
//class properties
protected $db;
//class construct
function __construct($_POST) {
$this->db = new DB(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$validate = new Validate;
$validate->uniqueEmail($_POST['email']);
}
}Code: Select all
public function uniqueEmail($input) {
$input = $db->escape($email);
$result = $db->query("SELECT * FROM user_auth WHERE email='$input'");
if($result->length() == 1) {
$_SESSION['error']['uniqueEmail'] = "Epostadressen används redan för annat konto";
}
}Code: Select all
Fatal error: Call to a member function escape() on a non-object in M:\Development\base.dev\lib\class.Validate.php on line 134Could anyone point me in the right direction on this?
thanks in advance
/Daniel