0

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;
    $_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" } }
2
  • there are several lines on line 248? Commented Nov 11, 2010 at 15:23
  • Can you point out in your code what line 248 is? Commented Nov 11, 2010 at 15:23

3 Answers 3

5

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) {
      }
*/
Sign up to request clarification or add additional context in comments.

4 Comments

how i can do that unserialize($_SESSION)
Sorry I was editing while you were posting. See my revised answer. In other words: jooria_user has to be declared in the script that accesses it from session.
no i save the session with ingeter i dont know what all this happedn
Apparently you aren't. $_SESSION['user'] is an object of type jooria_user, from what we can see from your var_dump.
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.

Comments

0

First I'd make sure all { } braces have pairs in the right place. A } missing from the last line would be my guess.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.