root folder problem

greg's picture

He has: 1,581 posts

Joined: Nov 2005

I'm using a free shared server (to do some live testing)

I have most php pages in the normal root folder of my server, all works fine.
from a file within this root folder, using a php include to a file in a upper level folder is fine, but when I take users INTO a upper level folder and use files in there, includes to lower level folders wont work?

i.e.

server folder layout:

/www/
folders in www folder are:
/css
/images
/members

files in www folder are:
index.php
contact.php
(etc)

index.php calls the files from images and css fine (/images/imagename.jpg)
but
when the user logs in and is then using the files in /members

require_once('/footer.php'); does not work?
if footer is copied to /members folder, and the code changed to...
require_once('footer.php'); it works fine

so how, on a shared server do I tell it to go to the correct folder to use a file?

I also tried the full http://www.freeserver.com/footer.php
same problem

He has: 698 posts

Joined: Jul 2005

Have you tried something like:

require_once $_SERVER['DOCUMENT_ROOT'] . "/footer.php";
'

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

'/footer.php' tells php to go all the way to your root file system which you most likely don't have permission to do. To go to a directory up, do '../footer.php'.

greg's picture

He has: 1,581 posts

Joined: Nov 2005

both worked, thanks peeps!

Cheers!

He has: 698 posts

Joined: Jul 2005

pr0gr4mm3r;221994 wrote: '/footer.php' tells php to go all the way to your root file system which you most likely don't have permission to do. To go to a directory up, do '../footer.php'.

The only problem with this is that if you wanted to specify the URL over several pages spanning several directories, a more absolute URL would be easier to manage. Wink

Kurtis

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.