Welcome Guest, Not a member yet? Register   Sign In
[Closed] error Undefined variable: query
#1

[eluser]riwakawd[/eluser]
Hello I have created a library for my users login what gets and updates stuff to and from data base. I am getting a error undefined variable : Query line 8 which in the one in the public function construct.

Not sure if have set the query correct for both public function and function login.

Code:
public function __construct() {
if ($query->num_rows() > 0) {
$this->user_id = $this->db->query('user_id');
$this->username = $this->db->query('username');
$this->db->query("UPDATE " . DB_PREFIX . "user SET ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE user_id = '" . (int)$this->session->userdata['user_id'] . "'");
} else {
$this->logout();
}
}

public function login($username, $password) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "user WHERE username = '" . $this->db->escape($username) . "' AND (password = SHA1(CONCAT(salt, SHA1(CONCAT(salt, SHA1('" . $this->db->escape($password) . "'))))) OR password = '" . $this->db->escape(md5($password)) . "') AND status = '1'");
$ip = $_SERVER['REMOTE_ADDR'];
$query = $this->db->query("UPDATE users SET ip = $ip WHERE user_id = $this->user_id");
if ($users_query->num_rows) {
$this->session->userdata['user_id'] = $user_query->row['user_id'];
$this->user_id = $user_query->row['user_id'];
$this->username = $user_query->row['username'];        
return true;
} else {
return false;
}
}

public function logout() {
$this->session->unset_userdata($user_id);
$this->user_id = '';
$this->username = '';
$this->session->sess_destroy();
}


Messages In This Thread
[Closed] error Undefined variable: query - by El Forum - 04-24-2014, 11:21 PM
[Closed] error Undefined variable: query - by El Forum - 04-24-2014, 11:37 PM
[Closed] error Undefined variable: query - by El Forum - 04-24-2014, 11:38 PM
[Closed] error Undefined variable: query - by El Forum - 04-24-2014, 11:42 PM
[Closed] error Undefined variable: query - by El Forum - 04-24-2014, 11:47 PM
[Closed] error Undefined variable: query - by El Forum - 04-24-2014, 11:50 PM
[Closed] error Undefined variable: query - by El Forum - 04-25-2014, 07:58 AM
[Closed] error Undefined variable: query - by El Forum - 04-25-2014, 08:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB