Welcome Guest, Not a member yet? Register   Sign In
DB/Query Error
#1

[eluser]Shujin[/eluser]
Code:
function is_staff()
    {
        $id = $this->ci->session->userdata('userid');
        $query = $this->ci->db->get_where('group_memberships', array('userid' => $id));
        $group = $query->row()->groupid;
        
        if ($group <= 2) {
            return true;
        }
    }

Which seems to give me this error:

Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: libraries/quickauth.php

Line Number: 184

But I have the exact same code right above (at Line: 173)
but it only detects the error at this line.
#2

[eluser]n0xie[/eluser]
What does this tell you if you put it at the end of your function?
Code:
var_dump($group);
#3

[eluser]Shujin[/eluser]
Ah it tells me NULL...

Although this was working before, so I have no idea what went wrong.
#4

[eluser]Shujin[/eluser]
It seems
Code:
$id = $this->ci->session->userdata('userid');

Returns a boolean rather than the actual "ID", any suggestions on how to get the actual ID from the session?
#5

[eluser]WanWizard[/eluser]
It returns the value stored in the session, or FALSE if that value does not exist.
#6

[eluser]Shujin[/eluser]
Ok, so this is the user_data from phpymadmin:
http://uploadir.com/u/1469aeb4

I don't know why it isn't finding what I want it to, i'm basing my code on what quickauth has used to get the userid in other functions, so I don't know why this isn't working...




Theme © iAndrew 2016 - Forum software by © MyBB