Re: Includes and paths confusion

From: Date: Fri, 28 Apr 2006 09:34:47 +0000
Subject: Re: Includes and paths confusion
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-234980@lists.php.net to get a copy of this message
Nick Wilson wrote:
Hello all, Im having some problems understanding why some requires() are failing. Let me see if i can describe what's going on clearly... I have this: nick@communicontent > ls ads/ config.inc db.inc funcs.inc init.inc where ads/ is a whole huge set of scripts from an existing setup. ads/ was originally placed on its own domain as it's a version of phpadsnew and runs as a server all by itself. I moved ads/ to this directory to try to troubleshoot and make things clearer. db.inc has these lines:
use something *like* the following: $oldincpath = ini_get('include_path'); ini_set('include_path', 'path/to/ads/stuff:etc'); // do your 'ads' requires ini_set('include_path', $oldincpath); also look into the magic constant __FILE__ and the functions dirname() and realpath(). read the manual regard how to use 'include_path' have fun.
require_once("ads/admin/config.php"); require_once("lib-statistics.inc.php"); require_once("lib-zones.inc.php"); require_once("config.inc.php"); require_once("lib-db.inc.php"); require_once("lib-dbconfig.inc.php"); warning: main(../config.inc.php): failed to open stream: No such file or directory in /var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin/config.php on line 33. Fatal error: main(): Failed opening required '../config.inc.php' (include_path='.:/usr/lib/php') in /var/www/localhost/vhosts/payment.communicontent.com/modules/partners/inc/ads/admin/config.php on line 33 So, why does this not happen when ads/ is on its own domain? I can see it has something to do with relative paths, but even when i try to work with chdir() i still get no joy. I just can't figure out what the issue may be, so any pointers in the right direction would be hugely appreciated. thankyou!


« previous php.general (#234980) next »