传递给each()的PHP变量不是数组

I have a class function below that caches a users information, what the error im getting is below

Warning: Variable passed to each() is not an array or object in C:\inetpub\wwwroot\application\base\classes\class.user.php on line 67

And the function is below.

public function cacheUserInfo() {
        if (!$this->loggedIn())
            return;

        global $autoLoader;
        $userQuery = $autoLoader->getLibrary('database')->query("SELECT motto,look,rank,last_login,block_newfriends FROM `users` WHERE `id` = '" . $_SESSION['user']['id']. "'");

        $userRow = mysqli_fetch_array($userQuery);

        while (list($var, $val) = each($userRow)) {
            $_SESSION['user'][$var] = $val;
        }
    }

The query function on database library is just the ->query($sql) function for a MySQLi connection.

It was working one second now its not... Why am I getting this error?

Why not just use

foreach($userRow as $key => $value)

It looks like your query might be returning null. If that's the case, maybe you should check if it is null first.

You don't need neither each nor foreach here.

All the code you need is just

$_SESSION['user'] =mysqli_fetch_assoc($userQuery);