Page 1 of 1
Includes not working since I upgraded to PHP5
Posted: Thu Mar 16, 2006 5:22 am
by dschad
Hi All,
I recently upgraded the PHP on our companies intranet server to PHP 5. This caused all of my includes in my PHP scripts to stop working.
Does anybody know how to solve this. I suspect that the problem is down to a setting in my php.ini file however I'm not sure what setting it could be.
I've tried changing the 'include_path' setting in php.ini but it doesn'se seem to have any effect.
Has anybody else had this problem and know how to fix it??
Thanks for your help in advance guys!
Posted: Thu Mar 16, 2006 5:45 am
by shiznatix
what do you mean they 'stop working'. How are you including them? Maybe there is a bigger problem because php5 works just fine when i include my files. show us a example code that does not work.
Posted: Thu Mar 16, 2006 6:11 am
by dschad
Ok my script includes another php script containing my database connection details using the following command:
include ("../connect.php");
The connect.php script is located in the directory above my main script. However when I run my main script it is not picking up the connect.php script in the directory above and so won't connect to the database. This worked ok in my old PHP 4 install.
Perhaps it has someting to do with the path to the included file, it doesn't appear to like the ../ part of the path??
It works if I have the included file in the same directory as the file where the include is called from, using just: include ("connect.php"), but I need the connect.php file in the directory above my main script.
Posted: Thu Mar 16, 2006 7:35 am
by Maugrim_The_Reaper
Maybe use of realpath()?
Posted: Thu Mar 16, 2006 7:38 am
by Chris Corbyn
Errors?
I assume you've got error reporting turned on?
Posted: Thu Mar 16, 2006 8:26 am
by dschad
Ok i've fixed the problem, the error that was getting reported was:
open_basedir restriction in effect. File(../connect.php) is not within the allowed path(s): (.;sys:/tmp)
I found the following entry in my php.ini file:
open_basedir = ".;sys:/tmp"
I then commented this line out and now it works. It seems that if the open_basedir is set, this limits file operations to the directories specified in the open_basedir setting. By commenting this line I'm assuming that it allows file operations in any directory rather than just limiting it to the specified directory.
Thanks for all your help.