RE: [PHP] __PHP_Incomplete_Class Errors...

From: Date: Thu, 28 Oct 2004 01:06:19 +0000
Subject: RE: [PHP] __PHP_Incomplete_Class Errors...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200507@lists.php.net to get a copy of this message
Ok, thanks, that cleared up one problem, but now I've got a new one. I have a few functions that contact with the database from the separate classes. One function in particular has many, which is this code: function login($user, $pass) { $sql = 'SELECT * FROM '.PREFIX.'users WHERE username="'.$user.'" AND password=password("'.$pass.'")'; $res = $this->db->query($sql); if($res) { if($this->db->num > 0) { if($this->db->row['active'] != 0) { $_SESSION['user'] = $this->db->row; $_SESSION['loggedin'] = 1; $sql = 'UPDATE '.PREFIX.'users SET lastactive=NOW() WHERE id="'.$_SESSION['user']['id'].'"'; $this->db->query($sql); return true; } else { return 'inactive'; } } else { return 'invalid'; } } else { return 'mysql'; } } This function works fine, up until it calls the second SQL query: $this->db->query($sql); At this point, the script crashes saying "Fatal error: Call to a member function on a non-object in /home/melchior/public_html/clients/tmp/login.php on line 41" Line 41 calls $user->login() which is the function above. What's odd is the fact the first script call works, since the session variable gets populated. If I comment out the second call, it works fine. Anyone have any ideas? ------------------------------------ Stephen Craton webmaster@melchior.us IM: webmaster@melchior.us http://www.melchior.us ------------------------------------ -----Original Message----- From: Curt Zirzow [mailto:php-general@zirzow.dyndns.org] Sent: Tuesday, October 26, 2004 22:55 To: PHP List Subject: Re: [PHP] __PHP_Incomplete_Class Errors... * Thus wrote Stephen Craton: > I've been working on a script for a while now and it works perfectly on my > local machine. I'm using a couple of classes, mainly my database and users > classes. > > After logging in, I assign a session variable to the user's row in the > database: $_SESSION['user'] = $db->row; > > This works fine locally, but on my hosted machine, it settings the variable > to this: > > __PHP_Incomplete_Class Object This means you are not defining your class before starting your session. If you store classes in a session you must define you class before the call to session_start(). If you have session.auto_start = 1 in your configuration, you will have to disable that so you can define your classes before starting the session. Curt -- Quoth the Raven, "Nevermore." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#200507) next »