can anyone tell me wht shud i do:
ERROR: Fatal error: Call to a member function getRecords() on a non-object in /home/***/public_html/includes/User.php on line 166
This is my USER.php FILE:
any IDEA?
ERROR: Fatal error: Call to a member function getRecords() on a non-object in /home/***/public_html/includes/User.php on line 166
This is my USER.php FILE:
PHP:
<?php
include_once(DOC_ROOT . 'includes/UData.php');
class User extends Main {
var $con;
function User()
{
$this->con =& parent::DB();
}
function getOne($uid)
{
$sql = 'SELECT *
FROM users
WHERE id = ' . (int) $uid;
$this->con->getRecords($sql);
return $this->con->data[0];
}
function userExists($uname)
{
settype($uname, 'string');
if (!empty($uname)) {
$sql = "SELECT username
FROM users
WHERE username = '$uname'";
$this->con->getRecords($sql, SQL_ONE);
if ($this->con->data) {
return true;
}
}
return false;
}
function passMatch($pass1, $pass2)
{
if (strcmp($pass1, $pass2) == 0) {
return true;
} else {
return false;
}
}
function add($form_vars, $uid)
{
if (isset($uid) && (int) $uid) {
$update = true;
} else {
$update = false;
}
if ($this->userExists($form_vars['username'])) {
$this->error[] = 'The username is already taken, please choose another';
return false;
}
if (isset($form_vars['password']) && !empty($form_vars['password'])) {
if (!$this->passMatch($form_vars['password'], $form_vars['password2'])) {
$this->error[] = 'The passwords do not match!';
return false;
}
$pass = $this->pw_encode($form_vars['password']);
} elseif ($update) {
$pass = 0;
} else {
$this->error[] = 'You must provide a password';
return false;
}
if($form_vars['has_shared_favs'] == "on"){
$has_shared_favs = 1;
}
else{
$has_shared_favs = 0;
}
if ($update) {
$this->con->update_array = array(
'firstname' => $form_vars['firstname'],
'lastname' => $form_vars['lastname'],
'gender' => $form_vars['gender'],
'email' => $form_vars['email'],
'icq' => $form_vars['icq'],
'has_shared_favs' => $has_shared_favs
);
if ($pass) {
$this->con->update_array['password'] = $pass;
}
$this->con->updateRecord('users', 'id = ' . (int) $uid);
} else {
$this->con->insert_array = array(
'id' => 'NULL',
'ip' => $_SERVER['REMOTE_ADDR'],
'username' => $form_vars['username'],
'firstname' => $form_vars['firstname'],
'lastname' => $form_vars['lastname'],
'gender' => $form_vars['gender'],
'email' => $form_vars['email'],
'icq' => $form_vars['icq'],
'date_added' => date('Y-m-d', time()),
'has_shared_favs' => $has_shared_favs,
'password' => $pass);
$this->con->addRecord('users');
}
return true;
}
function hmac($key, $data, $hash = 'md5', $blocksize = 64)
{
if (strlen($key)>$blocksize) {
$key = pack('H*', $hash($key));
}
$key = str_pad($key, $blocksize, chr(0));
$ipad = str_repeat(chr(0x36), $blocksize);
$opad = str_repeat(chr(0x5c), $blocksize);
return $hash(($key^$opad) . pack('H*', $hash(($key^$ipad) . $data)));
}
function pw_encode($password)
{
$seed = substr('00' . dechex(mt_rand()), -3) . substr('00' . dechex(mt_rand()), -3) . substr('0' . dechex(mt_rand()), -2);
return $this->hmac($seed, $password, 'md5', 64) . $seed;
}
function pw_check($password, $stored_value)
{
$seed = substr($stored_value, 32, 8);
return $this->hmac($seed, $password, 'md5', 64) . $seed==$stored_value;
}
function checkLogin($user, $pass)
{
settype($pass, 'string');
settype($user, 'string');
$sql = "SELECT id as uid, username, password
FROM users
WHERE username = '$user'";
$this->con->getRecords($sql);
if ($this->con->num_records == 1) {
$hash = $this->con->data[0]['password'];
$valid = $this->pw_check($pass, $hash);
if ($valid) {
$data = new UData($this->con->data[0]['uid'], $this->con->data[0]['username'], true);
return $data;
}
}
$data = new UData(null, null, false);
return $data;
}
/**Mariana functions*/
function getLastRegUsers($limit=20){
$sql = 'SELECT * FROM users ORDER BY firstname LIMIT '.$limit.'';
$this->con->getRecords($sql);
return $this->con->data;
}
/**Mariana functions*/
}
?>
any IDEA?