1 (edited by omikron 2009-02-05 15:08)

Topic: Help with error.

I have PunBB integrated into a website that has a login system.

Whenever I hit submit on the forum search I recieve;


Fatal error: Call to a member function on a non-object in /****/session.php on line 91

Session.php is part of the websites login - here are lines 79 though 110 of session.php.

   function checkLogin(){
      global $database;  //The database connection
      /* Check if user has been remembered */
      if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){
         $this->username = $_SESSION['username'] = $_COOKIE['cookname'];
         $this->userid   = $_SESSION['userid']   = $_COOKIE['cookid'];
      }

      if(isset($_SESSION['username']) && isset($_SESSION['userid']) &&
         $_SESSION['username'] != GUEST_NAME){
         /* Confirm that username and userid are valid */
91         if($database->confirmUserID($_SESSION['username'], $_SESSION['userid']) != 0){
            /* Variables are incorrect, user not logged in */
            unset($_SESSION['username']);
            unset($_SESSION['userid']);
            return false;
         }

         /* User is logged in, set class variables */
         $this->userinfo  = $database->getUserInfo($_SESSION['username']);
         $this->username  = $this->userinfo['username'];
         $this->userid    = $this->userinfo['userid'];
         $this->userlevel = $this->userinfo['userlevel'];
         $this->company = $this->company['company'];
         return true;
      }
      /* User not logged in */
      else{
         return false;
      }
   }

Line 91 is pulling this from another file;

   function confirmUserID($username, $userid){
      /* Add slashes if necessary (for query) */
      if(!get_magic_quotes_gpc()) {
          $username = addslashes($username);
      }

      /* Verify that user is in database */
      $q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      if(!$result || (mysql_numrows($result) < 1)){
         return 1; //Indicates username failure
      }

      /* Retrieve userid from result, strip slashes */
      $dbarray = mysql_fetch_array($result);
      $dbarray['userid'] = stripslashes($dbarray['userid']);
      $userid = stripslashes($userid);

      /* Validate that userid is correct */
      if($userid == $dbarray['userid']){
         return 0; //Success! Username and userid confirmed
      }
      else{
         return 2; //Indicates userid invalid
      }
   }

Anyone have any idea where the conflict could be?:/

Re: Help with error.

I dont know how to fix this but looking around:

Your constructor for someclass is not setting the someobject member variable correctly, so it remains a null reference, which causes the error.

Sorry. Unactive due to personal life.

Re: Help with error.

I edited my first port to include the beginning of the function starting at like 79, does this help at all?

Re: Help with error.

Utchin wrote:

I dont know how to fix this but looking around:

Your constructor forsomeclassis not setting thesomeobjectmember variable correctly, so it remains a null reference, which causes the error.

I am not sure where to go form here, will you please elaborate?

Re: Help with error.

I looked on a forum and found the message above, The words in bold were the persons variables they were using. My advice is make sure that your variables dont remain null when you call the code out.

Sorry. Unactive due to personal life.

Re: Help with error.

Ok yeah I was afraid you were referring to that post... That is the first thing I saw when I  Googled my error.

It wasn't any help...

That section of code works fine on every other page of the site so I was thinking it may be conflicting variables or something?

Re: Help with error.

Anyone that knows the punbb variables a little able to look at what might be conflicting?

Re: Help with error.

Think I figured out what is happening, but I am not sure how to fix it...

Seems that when search calls anything from search_functions.php it's not calling my php includes from include/user. Have a file called session.php which contains;

<?
include("../include/session.php");
if(!$session->logged_in){
header("Location: ../index.php");
}

?>

If I remove include/user/session.php and just put "include("../include/session.php");" at the top of search.php it works fine...

Anyone have any ideas?

Re: Help with error.

I have found out that whenever a search parameter finds nothing is when i get the error. So if i search for something I know exists in the forums everything is fine, if there are no results it gives;

Fatal error: Call to a member function on a non-object in /****/session.php on line 91

Does this make any sense? Where can I find what each search function does when it returns null?

Re: Help with error.

Do the devs of this forum software ever read the forums?

11

Re: Help with error.

Yes we do. However as this isnt mainly a 1.3 Issue I dont know what to suggest. Sorry.

Sorry. Unactive due to personal life.

Re: Help with error.

But can you tell me what the search functions do when they return no results? As that's the only time it errors out.