MyBB Community Forums

Full Version: Using USER variables in another page.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I've been staring at this problem for far too long, and searched far too many threads, and I still can't see the wood for the trees!

I have a forum, based at mystie.com/forum. So far so good.

I also have a eShop, at mysite.com/shop. The shop uses the same user table as the forum, so that if the user updates the password, the password is updated for both parts. The individual log-in works for both sections of the site, without fail! Fantastic!

However, I can't always get the user variables from myBB, when I access the shop. The idea is that the user logs into the forum, and then, if they like a product being discussed, they can select an existing link, and be taken to the shop, pre-logged in. I've included the require('..forum/global.php') line, but this returns errors, because the include files within the global file cannot be found, due to incorrect location.

What is the correct way/fix to be able to get the myBB variables from another page, held in another directory on the same server?

Any ideas would be great.

MAny thanks

Absolute.
Cool
I believe it's only one period if you're requiring a file from another folder...like this:

require "./forum/global.php";

without the brackets.
Thanks for the suggestion, but if I take out the period, it returns the error:
Warning: main(./forum/global.php): failed to open stream: No such file or directory in /home/......./......./shop/index.php on line 26

Many thanks

Absolute
Cool

sooo...it worked?
No. It returns the error mentioned in the above post. I must be missing something, but I can't see what it is!

Absolute
require("../forum/global.php");

First, it helps if you have brakets Wink. Next, that code will take it out of the

/shop/

folder into

/

then into

/forum/

to get global.php and include it. Provided the place you required global is a file in the

/shop/

folder, this should work.
PHP language constructs require, require_once, include, and include_once do not require parentheses, but I would recommend them.
Many thanks for the advice. I have now included the (), so the lines now read:

require ("../forum/global.php");

echo $mybb['username'];
echo $mybbuser['username'];
echo $mybb['uid'];

However, I still get a returned error, which is related to the includes within the global.php script. These are:

Warning: main(./inc/timers.php): failed to open stream: No such file or directory in /home/........./forum/global.php on line 14

Fatal error: main(): Failed opening required './inc/timers.php' (include_path='.:/usr/local/lib/php') in /home/........./forum/global.php on line 14

How do I over these?

Thanks again

Absolute
Cool
ah. You need to replace ./ with ../forum/ in the global.php file. A global find/replace should work.
decwxaqz - that worked, but not in my page. Basically, if I place require("../forum/global.php") in a blank document, I can call any $mybb variable, but if I place it inside my page, then I get blank values for all of the variables??????

Any ideas? Thanks for the help so far!

Absolute
Pages: 1 2