PDA

View Full Version : PHP Include - Call from root directory??



priestess_isis
November 13th, 2004, 13:21
I have different directories and they all use the same PHP Include files...
Right now, I have to put my Include files in all directories in order for a page within that directory to be able to "call" from it.
I tried calling the include files from a different directory, say I have a directory called "sitestuff" and in the index.php I put
<? include("/includes/nav.php") ?>
where /includes is a different directory that's NOT within "sitestuff" directory, but rather within the root directory. I save it and open it and I get an error page that says something about /include not being in /sitestuff.

Is there anyway to fix this?

knives
November 14th, 2004, 07:08
So, if I understand correctly, your directory looks like this:

-INCLUDES (DIR)
---nav.php
-SITESTUFF (DIR)
---index.php

In that case, try this in index.php:

<? include("../includes/nav.php") ?>

These two dots are telling PHP, that it should go back one folder, and search for /includes/nav.php.

priestess_isis
November 14th, 2004, 13:30
okay! thanks so much!