Catchable fatal error: Object of class __PHP_Incomplete_Class
i get this error
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in user.php on line 248 this is the line
function loadUser($userID)
{
global $db;
$res = $db->getrow("SELECT * FROM `{$this->dbTable}` WHERE `{$this->tbFields['userID']}` = '".$this->escape($userID)."' LIMIT 1");
if ( !$res )
return false;
$this->userData = $res;
$this->userID = $userID;
开发者_C百科 $_SESSION[$this->sessionVariable] = $this->userID;
return true;
}
see
var_dump($_SESSION);
array(1) { ["user"]=> &object(__PHP_Incomplete_Class)#1 (12) { ["__PHP_Incomplete_Class_Name"]=> string(11) "jooria_user" ["dbTable"]=> string(5) "users" ["sessionVariable"]=> string(4) "user" } }
Is this an object stored in session? Have you declared your class before retrieving the object from session?
In any case, my guess is that you're missing a class declaration somewhere.
EDIT: Your class jooria_user
is not declared before use. That is why you get that error.
Say you have this:
<?php
session_start();
class A {}
$a = new A;
$_SESSION['A'] = $a;
Then you try to access it in this script:
<?php
session_start();
$a = $_SESSION['A'];
var_dump($a);
/* outputs:
object(__PHP_Incomplete_Class)#1 (1) {
["__PHP_Incomplete_Class_Name"]=>
string(1) "A"
}
*/
Now if you do that instead:
<?php
class A {} // declares the class here
session_start();
$a = $_SESSION['A'];
var_dump($a);
/* outputs:
object(A)#1 (1) {
}
*/
Looks like the provided function-argument $userID
is an object and the error occurs here:
$this->escape($userID)
(I don't see any further string-operations that could force such an error).
So check out what's the argument you call loadUser()
with.
First I'd make sure all { }
braces have pairs in the right place. A }
missing from the last line would be my guess.
精彩评论