# php includes fail to open



## colorado97 (Mar 17, 2004)

I'm trying to set up a php newsletter script that has an included file, but the included file does not load properly. I get a message such as: 
Warning: Failed opening '../config.php' for inclusion (include_path='.;sys:/php/includes') in sys:/apache/html/newsletter/admin/newsletter.php on line 18
I've checked that the includes directory exists and I put a copy of the config.php file in the includes directory but I still get the same error. The .htaccess file in the includes directory said deny from all and I changed it to allow from all. Still the same error message. Any suggestions??


----------



## brendandonhu (Jul 8, 2002)

Just specify a full path to the file you want to include, instead of a relative path. It will save lots of headaches


----------



## colorado97 (Mar 17, 2004)

I tried specifying the full path and I'm still getting the same message. ??


----------



## brendandonhu (Jul 8, 2002)

What is the code you are using, and what is the full path to the file?


----------



## colorado97 (Mar 17, 2004)

<?
$header = include 'header.php';
include('../config.php');
//=======Begin=======//
if ($action == "begin") {
$db = mysql_connect($database_host, $database_username, $database_password) or die ("$header

$error_mysql_connect​"); ... etc.

The full path to the file containing the above code would be www.mywebsite.net/newsletter/admin/newsletter.php


----------



## brendandonhu (Jul 8, 2002)

Header.php needs to be in the same directory as newsletter.php, and config.php needs to be one level above.


----------



## colorado97 (Mar 17, 2004)

The header.php is in the correct directory and shows up on the page. Made sure the config.php file was in the next directory up but still get the following errors:

Warning: open_basedir restriction in effect. File is in wrong directory in sys:/apache/html/newsletter/admin/newsletter.php on line 18

Warning: Failed opening '../config.php' for inclusion (include_path='.;sys:/php/includes') in sys:/apache/html/newsletter/admin/newsletter.php on line 18


----------



## brendandonhu (Jul 8, 2002)

You didn't post that error the first time 

open_basedir restricts which folders you are allowed to use include()s in. Unless you have access to the PHP Configuration with your host, you will probably have to move the scripts to a different directory.

Create a script with this in it:

```
<?php phpinfo(); ?>
```
It will tell you which directories allow you to use includes.


----------



## colorado97 (Mar 17, 2004)

I do have access to the PHP configuration file on the server, but what would I have to change?


----------



## brendandonhu (Jul 8, 2002)

In php.ini, change open_basedir to NULL.


----------



## colorado97 (Mar 17, 2004)

Currently that value is set to open_basedir = ".;sys:/tmp". If I place the config.php file there would that take care of the problem? Or would it be better to change the php.ini file? However, the includes path is set to include_path =".;sys:/php/includes"


----------



## brendandonhu (Jul 8, 2002)

Change to php.ini file.


----------



## colorado97 (Mar 17, 2004)

Are there any security vulnerabilities that would be exposed by making that change?


----------



## brendandonhu (Jul 8, 2002)

Not if it is your server. It is used by webhosts that want to restrict access to the machine.


----------



## colorado97 (Mar 17, 2004)

Changed the value to NULL. Used nvadmdn and nvadmup to recognize the change, but still had to restart the server anyway. Problem resolved. Thanks.


----------



## brendandonhu (Jul 8, 2002)

I'm not sure, but yes you probably need to restart the server. I could be wrong though, might want to check the documentation on that one.


----------



## colorado97 (Mar 17, 2004)

Yes, I finally had to restart the server. But changing the php.ini value for open_basedir to NULL made all the difference. Thanks again for your help. Looks like I should make another donation.


----------



## brendandonhu (Jul 8, 2002)

You're welcome


----------

