Includes not working since I upgraded to PHP5

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dschad
Forum Newbie
Posts: 7
Joined: Wed Nov 05, 2003 8:23 am

Includes not working since I upgraded to PHP5

Post 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!
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post 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.
dschad
Forum Newbie
Posts: 7
Joined: Wed Nov 05, 2003 8:23 am

Post 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.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Maybe use of realpath()?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Errors?

I assume you've got error reporting turned on?

Code: Select all

<?php

error_reporting(E_ALL);

?>
dschad
Forum Newbie
Posts: 7
Joined: Wed Nov 05, 2003 8:23 am

Post 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.
Post Reply