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

[eluser]riwakawd[/eluser]
[quote author="InsiteFX" date="1398437915"]If he is accessing the database in a Library then he needs to get the CI Super object.

Code:
private $_ci;   // The CI Super object

public function __construct()
{
  $this->_ci = get_instance();
}

// Then he needs to use the methods like so

$this->_ci->session->set_userdata($data);


$query = $this->_ci->db->query("UPDATE users SET ip = $ip WHERE user_id = $this->user_id");

[/quote]

Have been watching some more videos on how to get session data I think this is OK just to grab the username and ip address just so can store the ip in user. I ts going to be easier when I set up my maintenance config in future.

Code:
function get_db_session_data() {
$query = $this->db->select('user_data')->get('ci_sessions');
$user = array(); /* array to store the user data we fetch */
foreach ($query->result() as $row) {

    $getdata = unserialize($row->user_data);
    $user['username'] = $getdata['username'];
    $user['ip_address'] = $getdata['ip_address'];
    $user['is_logged_in'] = $getdata['is_logged_in'];
}
    return $user;
}


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