1

I have the following code.

        public function get_users_theme($uid)
            {
                    $r = $this->db2->query('SELECT * FROM users_theme WHERE user_id="'.$uid.'" LIMIT 1', FALSE);
                    if ($this->db2->num_rows($r) > 0) {
                            $o->user_theme = new stdClass();
                            $ut = $this->db2->fetch_object($r);
                            foreach($ut as $l=>$s) {
                                    $o->user_theme->$l  = stripslashes($s);
            }
                            return $o->user_theme;
                    } else {
                            return FALSE;
                    }
            }

It appears that line 5 are producing the following error:

Strict standards: Creating default object from empty value

How Can I Fix That ?

Thanks

skaffman
  • 398,947
  • 96
  • 818
  • 769
iman aletaha
  • 31
  • 1
  • 8
  • 1
    possible duplicate of [PHP Strict standards: Creating default object from empty value - How to Fix?](http://stackoverflow.com/questions/1949966/php-strict-standards-creating-default-object-from-empty-value-how-to-fix) – Ernest Friedman-Hill May 18 '12 at 13:07

1 Answers1

4

$o has not been declared when you start to use it as an object, so just make it an stdClass object beforehand:

$o = new stdClass();
$o->user_theme = new stdClass();

Or, even better, replace $o->user_theme everywhere in that function with $user_theme - since your code doesn't seem to require a special object a normal variable will be sufficient.

Niko
  • 26,516
  • 9
  • 93
  • 110