Getting a require function to look in the right place
Posted on 2005-04-06
All of my php files being with the following line of code:
The file "required.php" initiates session variables, and sets up the database connection. Location of this file is www.mysite.com/files/required.php.
I recently moved to a new host, however, and that line of code no longer looks in the right place for that file.
My webhost suggested the following code:
$PHPRC = getenv('PHPRC');
ini_set("include_path", $PHPRC . "/home/myaccount/public_html");
This works, but I wish I didn't have to change the code on all of my files. Is there an easy way to update this site wide? I feel like I should be able to edit my include directory or something like that in php.ini, but I'm not clear on whether I can just post a php.ini file into my account or exactly what code to change in the sample php.ini from php.net. Also, how can I make this work with the code including the forward slash at the beginning of the location? The way it was at my last host, this code would find the file regardless of relative location.
Here's the code again that's at the top of my files:
Thanks for the help!