Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-12
4
Medium Priority
?
1,911 Views
Last Modified: 2008-01-09
Here is the ENTIRE error message I get:

=================
ERROR MESSAGE STARTS
=================

Fatal error: Call to a member function on a non-object in common.php on line 223

===============
ERROR MESSAGE ENDS
===============

Here is the file that the file it is referring to:

===============
FILE PHP CODE STARTS
===============

<?php
/***************************************************************************
 *                                common.php
 *                            -------------------
 *   begin                : Saturday, Feb 23, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: common.php,v 1.74.2.5 2002/12/17 23:59:37 psotfx Exp $
 *
 *
 ***************************************************************************/
/***************************************************************************
* phpbb2 forums port version 2.1 (c) 2003 - Nuke Cops (http://nukecops.com)
*
* Ported by Paul Laudanski (Zhen-Xjell) to phpbb2 standalone 2.0.4. Test
* and debugging completed by the Elite Nukers at Nuke Cops: ArtificialIntel,
* Chatserv, MikeM, sixonetonoffun, Zhen-Xjell. Thanks to some heavy debug
* work by AI in Nuke 6.5.
*
* You run this package at your sole risk. Nuke Cops and affiliates cannot
* be held liable if anything goes wrong. You are advised to test this
* package on a development system. Backup everything before implementing
* in a production environment. If something goes wrong, you can always
* backout and restore your backups.
*
* Installing and running this also means you agree to the terms of the AUP
* found at Nuke Cops.
*
* This is version 2.1 of the phpbb2 forum port for PHP-Nuke. Work is based
* on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
* on the phpbb2 standalone version 2.0.3. Our version 2.1 from Nuke Cops is
* now reflecting phpbb2 standalone 2.0.4 that fixes some major SQL
* injection exploits.
***************************************************************************/
/***************************************************************************
 *   This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
 *   by Tom Nitzschner (tom@toms-home.com)
 *   http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
 *
 *   As always, make a backup before messing with anything. All code
 *   release by me is considered sample code only. It may be fully
 *   functual, but you use it at your own risk, if you break it,
 *   you get to fix it too. No waranty is given or implied.
 *
 *   Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
 *   then on my site. All original header code and copyright messages will be maintained
 *   to give credit where credit is due. If you modify this, the only requirement is
 *   that you also maintain all original copyright messages. All my work is released
 *   under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

if ( !defined('IN_PHPBB') )
{
      die("Hacking attempt");
}

error_reporting  (E_ERROR | E_WARNING | E_PARSE); // This will NOT report uninitialized variables
set_magic_quotes_runtime(0); // Disable magic_quotes_runtime

//
// addslashes to vars if magic_quotes_gpc is off
// this is a security precaution to prevent someone
// trying to break out of a SQL statement.
//
if( !get_magic_quotes_gpc() )
{
      if( is_array($HTTP_GET_VARS) )
      {
            while( list($k, $v) = each($HTTP_GET_VARS) )
            {
                  if( is_array($HTTP_GET_VARS[$k]) )
                  {
                        while( list($k2, $v2) = each($HTTP_GET_VARS[$k]) )
                        {
                              $HTTP_GET_VARS[$k][$k2] = addslashes($v2);
                        }
                        @reset($HTTP_GET_VARS[$k]);
                  }
                  else
                  {
                        $HTTP_GET_VARS[$k] = addslashes($v);
                  }
            }
            @reset($HTTP_GET_VARS);
      }

      if( is_array($HTTP_POST_VARS) )
      {
            while( list($k, $v) = each($HTTP_POST_VARS) )
            {
                  if( is_array($HTTP_POST_VARS[$k]) )
                  {
                        while( list($k2, $v2) = each($HTTP_POST_VARS[$k]) )
                        {
                              $HTTP_POST_VARS[$k][$k2] = addslashes($v2);
                        }
                        @reset($HTTP_POST_VARS[$k]);
                  }
                  else
                  {
                        $HTTP_POST_VARS[$k] = addslashes($v);
                  }
            }
            @reset($HTTP_POST_VARS);
      }

      if( is_array($HTTP_COOKIE_VARS) )
      {
            while( list($k, $v) = each($HTTP_COOKIE_VARS) )
            {
                  if( is_array($HTTP_COOKIE_VARS[$k]) )
                  {
                        while( list($k2, $v2) = each($HTTP_COOKIE_VARS[$k]) )
                        {
                              $HTTP_COOKIE_VARS[$k][$k2] = addslashes($v2);
                        }
                        @reset($HTTP_COOKIE_VARS[$k]);
                  }
                  else
                  {
                        $HTTP_COOKIE_VARS[$k] = addslashes($v);
                  }
            }
            @reset($HTTP_COOKIE_VARS);
      }
}

//
// Define some basic configuration arrays this also prevents
// malicious rewriting of language and otherarray values via
// URI params
//
$board_config = array();
$userdata = array();
$theme = array();
$images = array();
$lang = array();
$gen_simple_header = FALSE;

include($phpbb_root_path . 'config.'.$phpEx);

if( !defined("PHPBB_INSTALLED") )
{
      header("Location: modules.php?name=Forums&file=install");
      exit;
}

global $forum_admin;
if ($forum_admin == 1) {
    //include("../../../db/db.php");
    include("../../../includes/constants.php");
    include("../../../includes/template.php");
    include("../../../includes/sessions.php");
    include("../../../includes/auth.php");
    include("../../../includes/functions.php");
} else {
    include("includes/constants.php");
    include("includes/template.php");
    include("includes/sessions.php");
    include("includes/auth.php");
    include("includes/functions.php");
}

//
// Mozilla navigation bar
// Default items that should be valid on all pages.
// Defined here and not in page_header.php so they can be redefined in the code
//
$nav_links['top'] = array (
      'url' => append_sid($phpbb_root_dir."index.".$phpEx),
      'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
);
$nav_links['search'] = array (
      'url' => append_sid($phpbb_root_dir."search.".$phpEx),
      'title' => $lang['Search']
);
$nav_links['help'] = array (
      'url' => append_sid($phpbb_root_dir."faq.".$phpEx),
      'title' => $lang['FAQ']
);
$nav_links['author'] = array (
      'url' => append_sid($phpbb_root_dir."memberlist.".$phpEx),
      'title' => $lang['Memberlist']
);

//
// Obtain and encode users IP
//
if( $_SERVER['HTTP_X_FORWARDED_FOR'] != '' )
{
      $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );

      if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $_SERVER['HTTP_X_FORWARDED_FOR'], $ip_list) )
      {
            $private_ip = array('/^0\./', '/^127\.0\.0\.1/', '/^192\.168\..*/', '/^172\.16\..*/', '/^10.\.*/', '/^224.\.*/', '/^240.\.*/');
            $client_ip = preg_replace($private_ip, $client_ip, $ip_list[1]);
      }
}
else
{
      $client_ip = ( !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) ) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ( ( !empty($HTTP_ENV_VARS['REMOTE_ADDR']) ) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : $REMOTE_ADDR );
}
$user_ip = encode_ip($client_ip);

//
// Setup forum wide options, if this fails
// then we output a CRITICAL_ERROR since
// basic forum information is not available
//
$sql = "SELECT *
      FROM " . CONFIG_TABLE;
if( !($result = $db->sql_query($sql)) )
{
      message_die(CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql);
}

while ( $row = $db->sql_fetchrow($result) )
{
      $board_config[$row['config_name']] = $row['config_value'];
}

if (file_exists('install') || file_exists('contrib'))
{
      message_die(GENERAL_MESSAGE, 'Please ensure both the install/ and contrib/ directories are deleted');
}

//
// Show 'Board is disabled' message if needed.
//
if( $board_config['board_disable'] && !defined("IN_ADMIN") && !defined("IN_LOGIN") )
{
      message_die(GENERAL_MESSAGE, 'Board_disable', 'Information');
}

?>

=============
FILE PHP CODE ENDS
=============

My question is:

01. What is this error referring to specifically?
02. How can I fix the problem?

The website that uses this php script is:

http://www.saeyouth.net/network/modules.php?name=Forums

This website was severely hacked a very long time ago, and I have spent the day fixing the for reproduction. I honestly don't understand how to fix this problem.

-Panos
0
Comment
Question by:marcoullisp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 17095757
It means that you are trying to execute a method (function of class) on a var that is not an object.
You will have to instantiate the object first
$db = new whateveryourobjectiscalled();
0
 

Author Comment

by:marcoullisp
ID: 17095790
Can you be more specific please in reference to the code I pasted?

-Panos
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 1000 total points
ID: 17095813
Well, if you take this line:
if( !($result = $db->sql_query($sql)) )
you see that $db is an object (notice the -> used to acces vars or methods of that class)
But you do not assign the object to $db because I don't see any line with:
$db =
In other words, $db is never set properly hence my first comment:
$db = new whateveryourobjectiscalled();
0
 

Author Comment

by:marcoullisp
ID: 17095836
So where would I place the  reference:

$db = new whateveryourobjectiscalled();

before or after if( !($result = $db->sql_query($sql)) )

Can you show me what the code should look like?

-Panos
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question