1 (edited by javan 2006-05-13 03:06)

Topic: globals not global when integrating with WordPress

I'm building a site that uses the pun_ functions across the entire site to maintain users while outside of the forum. I'm doing this by including the following code in the header of every page on my site:

define('PUN_ROOT', $_SERVER['DOCUMENT_ROOT'] .'/forum/');
define('PUN_QUIET_VISIT', 1);
require(PUN_ROOT . 'include/common.php');

This has worked great everywhere until I tried to include it in the header of a WordPress template, and received the following error:

Fatal error: Call to a member function query() on a non-object in /forum/include/functions.php on line 122

What I've found is that, for some very strange reason, the variables being made global at the top of the set_default_user() function are not actually becomming global and thus the query() method of  the $db object does not exist at that scope. If I reinstantiate the $db object inside of the function, that particular error goes away.

Any idea why this is happening?

Re: globals not global when integrating with WordPress

Does Wordpress use a $db variable that interferes?

3

Re: globals not global when integrating with WordPress

Smartys wrote:

Does Wordpress use a $db variable that interferes?

No, its database layer is stored in $wpdb

4 (edited by Smartys 2006-05-13 19:10)

Re: globals not global when integrating with WordPress

Line 122? There's no query there: did you mod functions.php in any way?

5

Re: globals not global when integrating with WordPress

I haven't modified the code at all, but I now have some commented out code in that function that I added myself. It's referring to the code that starts like this:

// Fetch guest user
$result = $db->query('SELECT

Again, the problem is that the $db object doesn't seem to be scoped inside of the function even though it is being defined as global. If I print_r($db) just before the function, it has properties, but inside of the function it doesn not.

6

Re: globals not global when integrating with WordPress

So.. has anyone successfuly integrated WordPress 2.0 and PunBB 1.2.11? They're certainly two very popular, open-source projects, and I'd be very interested to know if they've been integrated without running in to this error.

7

Re: globals not global when integrating with WordPress

I've received some emails as a result of this posting indicating that other people are having the exact same problem as me when integrating with WordPress and also Coppermine. I have not been able to find a solution.

Re: globals not global when integrating with WordPress

for  me i started out with wp, then i fount punbb
next i left wp alone
went to punbb and cutenews
http://huntsvilleclubz.com
i mod a css template and then added the punbb sesions and cookie info
then integrated cutenews to my creations.

or i just used punbb with a news mod that i hacked at til it displays the info on the front page.
http://bunpai.com
in the forum i list the coding how a few of my pages.

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: globals not global when integrating with WordPress

Hrmm, you could ask Coxis from guistyles smile I think he did it... (link)

10

Re: globals not global when integrating with WordPress

quaker, that's great that you got your site working without wordpress. i'm trying to make it work with it.

elbekko, that guistyles site doesn't combine wordpress and punbb, it just has a punbb thread about wp.