I’m resurrecting this thread because it deals directly with my question, and I’ve spent most of the day searching for something that will help me, and I couldn’t find the exact thing I was looking for…
I’m a complete PHP beginner, with no coding background to speak of, although I know HTML/XHTML/CSS thoroughly. I managed to use the require () statement(? - it IS a statement, right?) on my personal website to include my menu, using this code:
<?php require ("sitenav.txt" ); ?>
It took some trial and error for me to figure it out, but I finally got it working.
Now, I’m trying to do the same thing on a website I work on that’s hosted by DreamHost. I found this thread, but when I put
<?php include($DOCUMENT_ROOT."/php/fileHere.txt" ); ?>
(changing, of course, “fileHere.txt” to my file name, in this case “menu.txt”), nothing happens…it’s just blank where my menu is supposed to show up.
I think part of the problem might be my total ignorance of the “$_SERVER” and “$DOCUMENT_ROOT” variables…I’ve looked in about 50 million places on the net, including php.net, phpb.com, multiple message boards, and I can’t find out if I need to literally put something like this:
<?php include($_SERVER['document_root']."/php/menu.txt" ); ?>
<?php include($DOCUMENT_ROOT."/php/menu.txt" ); ?>
or if " ‘document_root’ " needs to be replaced with the path to my document root (I installed a phpinfo.php file and know what the path is)? I’m so freakin’ confused, and it’s just not clicking in my brain. Am I just being stupid, or is there something I’m not doing that will make my menu show up? I’ve been reluctant to post my problem, because I hate showing how ignorant I am, but I’ve been working on this most of the day with nothing to show for it but a headache. Php.net is overwhelming and pretty much greek to me (even the introductory tutorial starts to make my head hurt after a while), and other sites I’ve been on address the include statement but not the include path issues I’m having (or think I’m having). I feel like there’s something really simple I’m just not seeing, and it’s frustrating the hell out of me.
Any help is greatly appreciated…