I’ve spent the last hour searching the forums 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 another website I work on that’s hosted with a different hosting company…the menu should go in one of the table cells. It didn’t work to use the same code (that cell is just blank), so I started searching around. The company’s knowledge base was less than helpful, but I did manage to figure out that one of their users was using this code successfully (I switched to the include statement, since there seemed to be more info on it):
<?php include($DOCUMENT_ROOT."/php/fileHere.txt"); ?>
They did note that the host was running PHP 4.2.1, so that this would be better:
<?php include($_SERVER['document_root']."/php/fileHere.txt"); ?>
So, I’ve tried both of those. I created a “php” folder in my root directory (um, I think…that’s just the main directory under my domain name, correct? The place where my index.html file is kept?) and put my file (named menu.txt) in there. I’ve also tried putting “menu.txt” in my root directory and removing the “/php” from the path in the include statement.
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"); ?>
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… ![]()