RE: __PHP_Incomplete_Class Errors...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx
IM: webmaster@xxxxxxxxxxx
http://www.melchior.us
------------------------------------


-----Original Message-----
From: Curt Zirzow [mailto:php-general@xxxxxxxxxxxxxxxxx] 
Sent: Tuesday, October 26, 2004 22:55
To: PHP List
Subject: Re:  __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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux