MyBB Community Forums

Full Version: Promlem when running global.php from main site
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to integrate the forum with the rest of the site. I did the "define("IN_MYBB", 1);" and required the global.php file which then ran but then throws this error "Fatal error: Call to a member function simple_select() on a non-object in /home/daneslaw/public_html/forums/inc/class_datacache.php on line 80". I checked the class_datacache.php and when I did the code below both $db and $mybb show as null.

function cache()
	{
		global $db, $mybb;
		if($_SERVER['REMOTE_ADDR'] == '86.31.113.65') {
			echo var_dump($mybb);exit;
		}

The forum runs fine and the site runs the global.php file so I'm not sure what is going one. Any ideas?

Many thanks!
Does your site use a $db variable anywhere?
I'm using the Zend Framework which does use $db in places. I put the require global.php at the start of my index.php file before any ZF stuff is loaded and it works now. Thanks! Big Grin
(2012-07-03, 08:59 AM)Falesh Wrote: [ -> ]I'm using the Zend Framework which does use $db in places. I put the require global.php at the start of my index.php file before any ZF stuff is loaded and it works now. Thanks! Big Grin

You can't require a external file that defines the same global variable scopes as Zend does in your index.php, you must use a constructor class to work your way up.
If you require the global.php file infront of any other Zend objects with the same variable scopes then your Zend code would probably not work because you are defining global variables that are used within another core code that overwrites the ones that Zend uses.

I suggest you to use the MyBBIntegrator, it's built upon a constructor and classes to define the variables needed for mybb to work inside any other code.