PDA

View Full Version : Help on PHP includes


slideboxer
24 Dec 2001, 07:48
I'm trying to add some PHP includes to my sites home non-vB page. I'm not too familiar witht his stuff but I follow directions well :D Anyway, I'm using <? include("vbforums/filename.php"); ?> to read the info but I keep getting the following error:

Fatal error: Failed opening required './admin/config.php' (include_path='.:/usr/local/lib/php') in /home/www/mysite/vbforums/global.php on line 96

I've received this error on several different hacks I've attempted. What can i do to remedy this?

JamesUS
24 Dec 2001, 10:11
Try this (no idea if it will work but worth a try):


chroot("/home/www/mysite/vbforums/");
require("./global.php");
chroot("/home/www/mysite/");

slideboxer
26 Dec 2001, 05:55
I found I needed to use the chdir command. Oddly I'm having to use it with each and evry include on the page, not sure if that's the way ti's supposed to be ot not, but, it's all working. Thanks for the reply.

Mark Hensler
26 Dec 2001, 22:38
Easiest way is to just alter your include_path (http://www.php.net/manual/en/configuration.php#ini.include-path). There are two way you can do this...

Via .htaccess:
php_value include_path .:/home/www/mysite/vbforums:/home/www/mysite/php-includes

Via PHP:
ini_set("include_path", ini_get("include_path") . ":/home/www/mysite/vbforums:/home/www/mysite/php-includes");
I prefer using .htaccess because I can put it in my root web directory and the changes are global. It's a lot easier to edit one file than many.

PHP Docs: ini_set() (http://www.php.net/manual/en/function.ini-set.php), ini_get() (http://www.php.net/manual/en/function.ini-get.php)