Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Gold Sponsor 2015!
Can't figure out php include for the life of me :( crash41
I'm somewhat new to php (understatement).
We simply want to use php includes to reference the header and footer of a site. When the files are in the same directory - all is good. But they won't be. When i move them to where they will live - i get errors.
Any ideas? I've tried using the document root and nothing seems to help.
[ edited by: eelixduppy at 5:47 pm (utc) on Jan. 21, 2009] [edit reason] no personal URLs, please [/edit]
Do you have permissions to the files where they are now? Are you using the correct path? Everything spelled correctly?
There are a bunch of things that could be going wrong. Are you getting any errors from the script you are trying to include these files into?
Good question. How can i find that out? It does work when the include file is on the same level as the page i'm accessing crash41
As for the correct path - that might be my issue. I can't figure out how to code it. bkeep
when including a file I use relative paths so if the files are in the same directory lets say / you include the file like this
If you move the header into a directory say /includes/
What is the main file is about 3 levels DOWN (into) the site?
for example site struture is:
i want to include a file that is on the 'site' level. how do i do that?
include_once '../../../header.php'; give or take a "../" .. is up one level . is the current level ncw164x
you need to use the full server path to the include file and not the url of the site
include ("/what/ever/the/full/sever/path/to/the/include/file/is/footer.php"); ?>
then you need to make a file with whatever name you want to use, the example above would require a file name called footer.php, this can be any name you want it to be
Cool - that helps. But how to i know what the full server path is? crash41
Got it- dude. i'm an idiot.
thank you all!
no problem glad you got it sorted ;)
for the sake of anyone else looking to solve the same problem the full server path will be visible on the remote connection of the FTP program what is used to transfer your files