Forum Moderators: coopster
I am new to php and decided to convert my html site over to save myself time. I mde my includes file and put the footer/ navigation etc in there and everything is working perfectly except for my press folder. I have a folder with press releases and for the pages in the folder the navigation include won't work. I created another includes file for folder navigation and tried putting ../ but that didn't work. Does anyone know what I'm doing wrong?
Thank you!
I firmly recommend always using absolute file references; that means a complete path starting at the root of your server's filesystem.
Frequently, that will mean:
/var/www/html/includes/header.php (for example)
Your 'document root', i.e. the path to the root of your website (not the server) can always by found using:
$_SERVER['DOCUMENT_ROOT']
This means that your includes can be 100% reliably written as:
include($_SERVER['DOCUMENT_ROOT']."/includes/header.php");
In this way, you never need to worry about changing paths and links; it will always find the right place.
I've only been working with php for 2 months now so I'm sure I'm making a silly mistake.
Thank you in advance :-)
[edited by: FloridaCodeSlave at 3:15 pm (utc) on Mar. 15, 2008]
[edited by: eelixduppy at 5:55 am (utc) on Mar. 16, 2008]
[edit reason] example.com [/edit]
it's not a good idea to give out your actual domain plus the directory and file names stored outside of your root on a public website, by the way. the whole point of storing them outside your root is so they are secure. but if someone knows all the names then you're opening yourself to hacking.