Strange require_once(config.inc.php)

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
cjswanson1355
Forum Newbie
Posts: 10
Joined: Wed Nov 05, 2008 3:13 pm

Strange require_once(config.inc.php)

Post by cjswanson1355 »

Hello. Right now I am trying to set up a mail server, and I am having a heck of a time with this file. I did not write this, and I am completely baffled by this line of code.

require_once("config.inc.php");

This file does not exist in the directory, and when I check a working version of the program, it does not exist in the directory as well. Where else could require_once be pulling information from? A PHP extension I am not aware of? I am guessing it is related to pear but I really do not understand the libraries.

This is the error code it spits out

Warning: require_once(config.inc.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/html/******/********/index.php on line 25

Fatal error: require_once() [function.require]: Failed opening required 'config.inc.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/******/********/index.php on line 25
Last edited by cjswanson1355 on Wed Feb 04, 2009 3:01 pm, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Strange require_once(config.inc.php)

Post by John Cartwright »

PHP has something called an include path, where you can predefine the directories where PHP should attempt to load the file from, i.e. PEAR.

Take a look at

Code: Select all

echo get_include_path();
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Strange require_once(config.inc.php)

Post by Benjamin »

Can you post the code above that line please? Also, is this file included by a different file? For example:

index.php
config.inc.php
/includes/somefile.php

If you request index.php, the current directory is / (for the purposes of this example). Now if index.php includes includes/somefile.php, this does not change the current working directory. somefile.php could then include config.inc.php without error.
cjswanson1355
Forum Newbie
Posts: 10
Joined: Wed Nov 05, 2008 3:13 pm

Re: Strange require_once(config.inc.php)

Post by cjswanson1355 »

The only code above that line is some documentation. and the start php header. This is pulling from a different file.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Strange require_once(config.inc.php)

Post by John Cartwright »

You didn't address my response to the include path, nor to whether the file is being included from another page. :?
cjswanson1355
Forum Newbie
Posts: 10
Joined: Wed Nov 05, 2008 3:13 pm

Re: Strange require_once(config.inc.php)

Post by cjswanson1355 »

So after echoing the include path i get

/usr/share/pear:/usr/share/php'

Am I correct in assuming I need to create this directly and get the config file from my admin and put in in there.
cjswanson1355
Forum Newbie
Posts: 10
Joined: Wed Nov 05, 2008 3:13 pm

Re: Strange require_once(config.inc.php)

Post by cjswanson1355 »

n/m, I found out i need to access the webpage through a region.
Post Reply