View Full Version : referencing root directories

01-24-2004, 07:12 AM
I've moved some php files to various sub-directories and now the includes aren't displaying. (ie. I've moved http://xyz.net/company.php to http://xyz.net/company/index.php)

Using "/" allows images, js files, etc to show, but php includes will not. I'm sure there is an easy fix and I think I may have seen it before, but I've reached an impasse.

This doesn't work:

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

This does

<img src="/art/spacer.gif">


01-27-2004, 12:53 PM
dead easy - get rid of the initial / when including with php

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


01-28-2004, 12:45 AM
Root paths do work, but your server root is almost certainly not the same as your domain root - it might be "/home/webs/clients/xyz/public_html" or something.

You can do this instead:

<?php include($_SERVER["DOCUMENT_ROOT"] . "/includes/nav.inc"); ?>

01-28-2004, 04:38 AM
You can do this instead:

<?php include($_SERVER["DOCUMENT_ROOT"] . "/includes/nav.inc"); ?>

This doesn't work. :(

01-28-2004, 08:23 AM
brothercake used a different file name than you did in his example. You had "inc.nav.php", and brothercake had "nav.inc". Perhaps it is as simple as that... ever check the obvious.