MyBB Community Forums

Full Version: How to call global.php from a different directory?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

How can I successfully call global.php from a different directory? Say my forum is installed on the root directory and I want to call global.php from /directory1/... how can I do it?

require "./global.php" doesn't work
require "../global.php" doesn't work
require "../../global.php" doesn't work
require "http://www.mydomain.com/global.php" doesn't work
require "/home/myaccount/public_html/global.php" doesn't work

Any ideas? For the exact errors received, please see the following thread:
http://community.mybboard.net/thread-6615-page-9.html

I am posting this here because I have been bumping the above thread for two weeks asking for help and it has been ignored. I don't think enough people visit that section of the forum.

I really need to get this working. Your help will be much appreciated.

Thanks.
It works perfectly for me doing something like this:

define("IN_MYBB",1);
chdir('forum/'); // Or the path to your forum
require './global.php'; 

My setup is like this:
- Forum
- Wiki
- Bugtracker
- Game
index.php

Putting the code into index.php allows me to do myBB function etc. as you would expect...

Watch out though - chdir changes the directory (as the function implies). It can interfere with other scripts!!

If you need anymore help feel free to ask ^_^...
Perfect. I wish you could have seen my posts for help in the other thread. Wink

Much appreciated. I will let you know if I run into any further troubles.
You're welcome... glad it worked!

Smile