Click to See Complete Forum and Search --> : [RESOLVED] A non-web-accessible directory problem


elegion
08-22-2006, 12:10 PM
I’m new to PHP, and I have a fairly easy question to ask, how do I know if it is a non-web accessible directory, and where do I place that directory?

I basically created a directory called “includes”. And then moved all my php files to that directory. After which, I created and implemented the following code in the web accessible root directory:

require (“/www/includes/somefile.php”); (didn’t work, tried it without /www/)[/PHP]

All in all, I’ve tried to call the files in /includes/index.php online, but nothing seemed to work. Is there something I’m missing, or doing wrong?


Thank you for your time.

NogDog
08-22-2006, 12:35 PM
require/include use file system paths, not paths relative to the web document root. So you'll either need to use a full filesystem path, such as /home/username/public_html/includes/file.php, or to make it more portable:

require $_SERVER['DOCUMENT_ROOT']."/includes/file.php";

Or, if you created your includes directory at the same level as your public_html or htdocs directory:

require $_SERVER['DOCUMENT_ROOT']."/../includes/file.php";

Perhaps easiest is to add your include directory (full filesystem path) to your include_path (http://www.php.net/manual/en/ini.core.php#ini.include-path) setting in php.ini or .htaccess file.

elegion
08-23-2006, 04:16 AM
Thank you Nogdog, you really helped me out.