Page 1 of 1

Require()?? absolute path.[SOLVED]

Posted: Wed Oct 10, 2007 7:30 am
by james3302
I need to use the require function but I need to use a absolute path such as g:\website\inetpub\wwwroot\php

Is that possible? Here the dir structure

PHP-under PHP is Area, Armis, Live
Area, Armis and LIve each have North South West folders.


There are files in each North South West folder that make a DB connection. The guy who made the files put the connection details in each file and I am wanting to make one file and require it. I am wanting to put it into the php folder so that all the files can call it. I have tried

require("g:\website\inetpub\wwwroot\php\SoutDBConnection.php");

and it did not work.

Posted: Wed Oct 10, 2007 11:51 am
by feyd
Unless the path is on a different drive from where PHP runs (getcwd()) you may want to set/add-to the include path in php.ini instead.

Posted: Wed Oct 10, 2007 12:05 pm
by s.dot
The code you have should work. I do it all the time. Verify that the file exists, and turn on error reporting.

include in php.ini

Posted: Thu Oct 11, 2007 10:27 am
by james3302
not every php file needs this file though. If I include it in the php.ini file then will every php file run it?

Posted: Thu Oct 11, 2007 10:28 am
by John Cartwright
You would only set the path of the file in the php.ini, not the file itself. Then, to simply include the file you would do

Code: Select all

include 'SoutDBConnection.php';

Re: include in php.ini

Posted: Thu Oct 11, 2007 10:29 am
by feyd
james3302 wrote:not every php file needs this file though. If I include it in the php.ini file then will every php file run it?
You wouldn't set the full path to the file, only the path (without the filename.) Including would then be simply asking for the filename.

on a different drive

Posted: Fri Oct 26, 2007 3:59 pm
by james3302
PHP is installed on the C drive and the php files are on the G drive

and how do you turn on error reporting?

okay im back

Posted: Thu Nov 08, 2007 10:31 am
by james3302
Had some server issues but Im back to working on this. The HD is partitioned into a C drive and a G drive. PHP is installed on the C drive and the website is on the G drive. If you suggest adding something to the php.ini file then please give me an example of how to add it. or any other suggestions I can try.

I have

;include_path = ".c:\php\includes"

which means its commented out, I just change that to

include_path = ".g:\website\..."

and then in the files use require(SouthDBConnection.php)

Well

Posted: Mon Nov 12, 2007 7:17 am
by james3302
The absolute path worked this time. Last time it did not(that's why I posted this here). I can not take the line out of the php.ini file.