mikevarela Posted February 23, 2009 Share Posted February 23, 2009 For the life of me, I can't get this to work. I'm a little new too. Want to create a standard set of nav links for the whole site, so I'm trying to do it as an include. Here's what i have so far ---- <body> <div class="wrapper"> <div class="header"> <div class="logo"> <h1 class="logo">Nuance<span class="logo-light">Tone</span></h1> </div> <?php include ('navigation.php') ;?> </div> <div class="middle-left"> <h2>Boutique Audio Post</h2> <p>NuanceTon......... ----- then in the include file - which is named navigation.php in the root directory <html> <body> <div class="navigation"> <ul> <li><a href="index.php">home</a> </li> <li><a href="contact.php">contact</a> </li> <li><a href="audiopost.php">audio post</a> </li> <li><a href="vo.php">vo</a> </li> <li><a href="dj.php">dj</a> </li> <li><a href="reel.php">reel</a></li> </ul> </div> </body> </html> ------- any help with how to make this work. I keep getting this error. Warning: include(navigation.php): failed to open stream: No such file or directory in /- on line 16 Warning: include(): Failed opening 'navigation.php' for inclusion (include_path='.:') in /- on line 16 Quote Link to comment https://forums.phpfreaks.com/topic/146551-need-help-with-includes/ Share on other sites More sharing options...
BloodyMind Posted February 23, 2009 Share Posted February 23, 2009 I see nothing wrong with that, your navigation.php file has to be in the same directory as the first php file check your spelling and the location of the file Quote Link to comment https://forums.phpfreaks.com/topic/146551-need-help-with-includes/#findComment-769384 Share on other sites More sharing options...
rhodesa Posted February 23, 2009 Share Posted February 23, 2009 also, your include file should just contain a snippet of code (aka get rid of the html & body tags), otherwise the final code would look like: <body> <div class="wrapper"> <div class="header"> <div class="logo"> <h1 class="logo">Nuance<span class="logo-light">Tone</span></h1> </div> <html> <body> <div class="navigation"> <ul> <li><a href="index.php">home</a> </li> <li><a href="contact.php">contact</a> </li> <li><a href="audiopost.php">audio post</a> </li> <li><a href="vo.php">vo</a> </li> <li><a href="dj.php">dj</a> </li> <li><a href="reel.php">reel</a></li> </ul> </div> </body> </html> </div> <div class="middle-left"> <h2>Boutique Audio Post</h2> <p>NuanceTon......... which is no good Quote Link to comment https://forums.phpfreaks.com/topic/146551-need-help-with-includes/#findComment-769389 Share on other sites More sharing options...
mikevarela Posted February 23, 2009 Author Share Posted February 23, 2009 Thanks for the help guys, I actually thought about not including the HTML and BODY tags in the include file, so I've deleted them, leaving just the UL. I returned the opening and closing DIV tags for the navigation spot int he index file, just leaving the include () inside, linking to the include file. Still won't work, can't figure it out. Quote Link to comment https://forums.phpfreaks.com/topic/146551-need-help-with-includes/#findComment-769400 Share on other sites More sharing options...
premiso Posted February 23, 2009 Share Posted February 23, 2009 When all else fails use absolute paths. <?php include ($_SERVER['DOCUMENT_ROOT'] . '/folder/where/nav/is/in/navigation.php') ;?> Simply replace the /folder/where/nav/is/in with the right folder and that should work. Quote Link to comment https://forums.phpfreaks.com/topic/146551-need-help-with-includes/#findComment-769402 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.