root folder problem
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
kazimmerman posted this at 19:40 — 22nd July 2007.
He has: 698 posts
Joined: Jul 2005
Have you tried something like:
require_once $_SERVER['DOCUMENT_ROOT'] . "/footer.php";
pr0gr4mm3r posted this at 20:56 — 22nd July 2007.
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 posted this at 17:02 — 23rd July 2007.
He has: 1,581 posts
Joined: Nov 2005
both worked, thanks peeps!
kazimmerman posted this at 17:17 — 23rd July 2007.
He has: 698 posts
Joined: Jul 2005
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.
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.