__PHP_Incomplete_Class Errors...

__PHP_Incomplete_Class Errors...

am 27.10.2004 04:34:48 von 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
(
[__PHP_Incomplete_Class_Name] => users
[user] =>
[loggedin] => 1
[ip] => 12.222.81.78
[db] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => thedatabase
[host] => localhost
[user] => melchior_clients
[pass] => ****************
[data] => melchior_clients
[linkid] => 0
[res] => 0
[num] => 0
[row] =>
[logger] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => logger
[logdir] => logs/
[fp] =>
)

)

[logger] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => logger
[logdir] => logs/
[fp] =>
)

)

For some reason, as far as I can tell, it's making every class variable to
__PHP_Incomplete_Class for some reason. The way I'm accessing the classes
via another class this something like this:

$db = new theDatabase;
$user = new Users;
$user->db = $db;

And then, within the class, I access it as such:

$this->db->query($sql);

This works perfectly on my local machine, but it gets all weirded once I
upload it. I have NO idea why or how to fix it. Does anyone have any ideas?

------------------------------------
Stephen Craton
webmaster@melchior.us
IM: webmaster@melchior.us
http://www.melchior.us
------------------------------------

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

Re: __PHP_Incomplete_Class Errors...

am 27.10.2004 05:54:55 von Curt Zirzow

* 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

RE: __PHP_Incomplete_Class Errors...

am 28.10.2004 03:06:19 von Stephen Craton

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

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

Re: __PHP_Incomplete_Class Errors...

am 11.11.2004 12:26:46 von nick.rich

Stephen Craton wrote:

> 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
> (
> [__PHP_Incomplete_Class_Name] => users
> [user] =>
> [loggedin] => 1
> [ip] => 12.222.81.78
> [db] => __PHP_Incomplete_Class Object
> (
> [__PHP_Incomplete_Class_Name] => thedatabase
> [host] => localhost
> [user] => melchior_clients
> [pass] => ****************
> [data] => melchior_clients
> [linkid] => 0
> [res] => 0
> [num] => 0
> [row] =>
> [logger] => __PHP_Incomplete_Class Object
> (
> [__PHP_Incomplete_Class_Name] => logger
> [logdir] => logs/
> [fp] =>
> )

> )

> [logger] => __PHP_Incomplete_Class Object
> (
> [__PHP_Incomplete_Class_Name] => logger
> [logdir] => logs/
> [fp] =>
> )

> )

> For some reason, as far as I can tell, it's making every class variable to
> __PHP_Incomplete_Class for some reason. The way I'm accessing the classes
> via another class this something like this:

> $db = new theDatabase;
> $user = new Users;
> $user->db = $db;

> And then, within the class, I access it as such:

> $this->db->query($sql);

> This works perfectly on my local machine, but it gets all weirded once I
> upload it. I have NO idea why or how to fix it. Does anyone have any ideas?

> ------------------------------------
> Stephen Craton
> webmaster@melchior.us
> IM: webmaster@melchior.us
> http://www.melchior.us
> ------------------------------------

I had the same problem when storing objects in the session, this link will
tell you
how to solve your problem
http://lists.evolt.org/archive/Week-of-Mon-20031027/150721.h tml
rgs,
Nick

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