Fatal error: Call to a member function on a non-object in

Discussion in 'PHP' started by monosodium, Jul 1, 2011.

  1. #1
    Hello I'm not a PHP developer but a friend of mine is having problems so I'm trying to figure something out.

    Fatal error: Call to a member function on a non-object in

    This vague error occurs for 3 different scripts (trigger in red).

    First script lib/db.class.php

      function Read($key) {
        global $ADODB_SESS_CONN, $ADODB_SESS_MD5;
        //echo "read<br>";
        $data = '';
        if ($ADODB_SESS_CONN) {
          $query = "select data from idx_sessions where sesskey = '$key' AND expiry >= " . time();
          $result = $ADODB_SESS_CONN->Execute($query);
          [COLOR="red"]if ($result->RecordCount()) {[/COLOR]
           $data = rawurldecode($result->Fields('data'));
          }
          $ADODB_SESS_MD5 = md5($data);
          $result->Close();
        }
        return $data;
      }
    Code (markup):
    Second script lib/misc.lib.php

      function GetWhosOnline($exp = 600) {
        global $dbConn, $whosonline;
    
        if (!empty($whosonline))
          $exp = $whosonline;
    
        $expired = time() - $exp;
    
        // get total users online
        $query   = "select data from idx_sessions where expiry > $expired
                    order by expiry desc";
        $result  = $dbConn->Execute($query);
    
        $ret[0] = 0;
        $ret[1] = 0;
        $ret[2] = 0;
        $ip_arr = array();
        while (!$result->EOF) {
        [COLOR="red"]  $data = $result->Fields(data);[/COLOR]
          $data = urldecode($data);
    
          // parse session data
          $data = substr($data, 0, strlen($data) - 1);
          $str  = explode(";", $data);
    
          $dump = array ();
    
          foreach ($str as $key => $val) {
            $str1 = explode("|", $val);
            foreach ($str1 as $key1 => $val1) {
              if (preg_match("/s:/i", $val1))
                $dump[$vkey] = unserialize($val1);
              else
                $vkey = $val1;
            }
          }
    
          if (!in_array($dump[indexu_session_ip], $ip_arr)) {
            $ip_arr[] = $dump[indexu_session_ip];
            $username = $dump[indexu_session_username];
            if (!empty($username)) {
              $ret[] = $username;
              $ret[1]++;
            }
            else {
              $ret[2]++;
            }
            $ret[0]++;
          }
    
          $result->MoveNext();
        }
    
        // fix $_SESSION bug
        if ($ret[0] == 0) {
          $ret[0] = 1;   // total
    
          if (isset($_COOKIE['COOKIE_USERNAME'])) {
            $ret[1] = 1; // member
            $ret[3] = $_COOKIE['COOKIE_USERNAME'];
          }
          else
            $ret[2] = 1; // guest
        }
    
        return $ret;
      }
    
    Code (markup):
    Third script lib/link.class.php

         // pagination
    
          if ($this->paging) {
            if (empty($pg_which)) {
              $pg_which = 1;
            }
            $result                        = $dbConn->PageExecute($this->query, $pg_which, $this->pg_size);
          [COLOR="red"]  $this->record_count_of_display = $num_rows = $result->RecordCount();[/COLOR]
            $nav                           = new navigator;
            $nav->pg_size                  = $this->pg_size;
            $nav->href                     = $this->href;
            $nav->more_param               = $this->more_param;
            $nav->page_file                = $this->page_file;
            $nav->page_title               = $this->page_title;
            $nav->pg_which                 = $pg_which;
            $nav->rec_count                = $num_rows;
            $nav->init();
            $this->pagination              = $nav->print_all();
            $i                             = $nav->rec_start;
            $this->max_rows                = 100000;
          }
          else {
            $result                        = $dbConn->Execute($this->query);
            $this->record_count_of_display = $num_rows = $result->RecordCount();
            $i                             = 0;
          }
    
    Code (markup):
    If I comment out the bits triggering the error, things like captcha stop working. I'm guessing the script has trouble reading from the database. Any suggestions?
     
    monosodium, Jul 1, 2011 IP
  2. monosodium

    monosodium Well-Known Member

    Messages:
    1,028
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    100
    #2
    Oh I should add that the VPS these scripts are on ran out of inodes some time ago, I'm speculating that that might have something to do with it.
     
    monosodium, Jul 1, 2011 IP