1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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

Discussion in 'PHP' started by 123GoToAndPlay, Apr 19, 2006.

  1. #1
    Hi all,

    I am trying to get phpBB's login on my Wordpress blog. I created a simple login file which works.


    When I try to include this file in Wordpress I get the following error:
    
    Fatal error: Call to a member function on a non-object in 
    /path_to/sessions.php on line 134
    
    Code (markup):
    
    $sql = 'SELECT *
    			FROM ' . USERS_TABLE . '
    			WHERE user_id = ' . (int) $user_id;
    	
    		if (!($result = $db->sql_query($sql)))
    		{
    			message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
    		}
    		$userdata = $db->sql_fetchrow($result);
    		$db->sql_freeresult($result);
    
    Code (markup):
    Line 134: if (!($result = $db->sql_query($sql)))

    I already tried to add global $db; no luck

    Any other suggestions??
     
    123GoToAndPlay, Apr 19, 2006 IP
  2. Mystique

    Mystique Well-Known Member

    Messages:
    2,579
    Likes Received:
    94
    Best Answers:
    2
    Trophy Points:
    195
    #2
    probably you added a mod and you forgot to update the tables.

    Some mods come with the tables required to alter the database, some others need a manual setting.

    If you have a backup of the original database before the mod, dump it again and start from zero making the database alteration first.

    This can also be the result of upgrading the script, check this out:

    http://www.phpbb.com/styles/forum/v...id=c5b0a68e95716557681b8a1223aaf2dd&style=237
     
    Mystique, Apr 19, 2006 IP
  3. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #3
    Are you sure $db was instantiated as a class object?
     
    digitalpoint, Apr 19, 2006 IP
  4. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    To continue on from what digitalpoint said, are you sure that you've included the file that declares $db correctly?
     
    TwistMyArm, Apr 19, 2006 IP
  5. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Tx guys for your answers

    hmm, I did some phpbb modifications but these modifications work correct. I mean my phpBB forum works fine. I had a clean start with phpbb 2.02 (the latest). My modifications are just for SEO.

    Calling the simple login page works fine also.

    Including the simple login page in WP enviroment causes a problem.

    I have read a lot about this subject, apparently a well known issue between WP and phpBB. I read it could be "a query being called outside the session function".

    Trying to grasp this problem, at the start of this particular function I see
    
    function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0, $admin = 0)
    {
    	global $db, $board_config;
    	global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;
    ........
    ........
    
    Code (markup):
    As my phpbb works fine I guess $db is instantiated well

    Could it be WP and phpBB are using the same named globals, which conflicts???

    Any suggestions??
     
    123GoToAndPlay, Apr 20, 2006 IP