Jump to content

Strict Standards: Creating default object from empty value


TeddyKiller

Recommended Posts

Strict Standards: Creating default object from empty value

 

What does that error mean? The offending line is line 38.

Line 38 = $user->$key = $value;

 

The whole code for that area is-

            $query = $db->execute("select * from `users` where `id`=?", array($_SESSION['userid']));
            $userarray = $query->fetchrow();
            if ($query->recordcount() == 0)
            {
                session_unset();
                session_destroy();
                header("Location: index.php");
                exit;
            }
            foreach($userarray as $key=>$value)
            {
                $user->$key = $value;
            }
            return $user;

 

I also get a notice.

Notice: Undefined index: act in /home/katarra/public_html/fishing.php on line 60

 

Line 60 = if ($_GET['act'] == "fish")

 

The whole code for that bit is

if ($_GET['act'] == "fish") 
{
    
    if ($player->pole < 1) 
       {
        echo "You do not have a fishing pole!";
        exit;
    
    } 
else { // some other stuff which is irrelevant }

 

With the notice, it's recognising that the user has no poles, when infact.. you can even have a million and it'll still give the notice.

 

Can anyone help?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.