PDA

View Full Version : use the config?


frandy
08-12-2006, 10:58 PM
Right so im making my own script, and its going to be located out with the "forum" directory etc so my page will be index and im wanting to use the config file thats found in the /forum/includes/config.php but see...theres one slight problem...how to I make a connection to the database with that config file?

Ive never worked with one such like that, its always been like

$usern = usern;
$pass = pass;

where as vbulletin is like:

$config['masterdb']['username'] =

and so on...if someone can explain how I would connect using this (as I do not wish to make my own config file either)

Cheers

Anyone? I need this for a project :-(

AN-net
08-16-2006, 02:57 PM
if i am understanding correctly, it will be out of the forum directory?

if so use this:

chdir(fullpathtoforums);

now your full path to your forums maybe something like this:
/home/frandy/public_html/forums/

if you are not sure, make a new php file executing this:

echo "My path info is:" . getcwd();

upload that file to your forum directory and run it, this will echo your file path of your forum directory.

copy that and place it in the chdir() function. then for easy access to vb variables and the database vbulletin uses just require_once() global.php, like so:

chdir(fullpathtoforums);
require_once('./global.php');


then if you need access files in the same directory as your new script
simply run this:

chdir(getcwd());


and then include files from your current directory.

more info on chdir() and getcwd():

chdir() (http://us2.php.net/manual/en/function.chdir.php)
getcwd() (http://us2.php.net/getcwd)