Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts

    Include Function with Nav

    Hey, im just following a tutorial in a book i bought but i am having trouble.

    i did every they they say and i am still getting the following error:
    Warning: main(includes/menu.php) [function.main]: failed to open stream: No such file or directory in /home/www/nrtdesigns.com/index.php on line 15

    Warning: main() [function.include]: Failed opening 'includes/menu.php' for inclusion (include_path='.:/usr/local/php4/lib/php') in /home/www/nrtdesigns.com/index.php on line 15
    What i am trying to do is use the include function so that my nav is in a seperate php file. this way i only need to update one file to change the nav across all pages on my site.

    what i did:
    1. saved my index page as index.php
    2. replaced the html for my nav with
    PHP Code:
     <?php include('includes/menu.php'); ?>
    3. put the html for my nav in a seperate file named menu.php
    4. uploaded to my web host and viewd in a browser

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Did you put menu.php in a directory called "includes" or is it in the same directory as index.php?

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    it is in the same directory as index

  • #4
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    awww, and i see my prorblem! thanks for that little nudge in the right direction!

    However now, my php nav does not have any of my css formating.

    what i have:
    menu.php:
    Code:
    	   	<ul>
    	    <li> <a href="index.htm" id="homelink"> Home </a> </li>
    	    <li> <a href="about.htm" id="aboutlink"> About Us </a> </li>
    	    <li> <a href="portfolio.htm" id="portfoliolink"> Portfolio </a> </li>
    	    <li> <a href="getasite.htm" id="pricelink"> Get a Site </a> </li>
    	    <li> <a href="contact.htm" id="contactlink" class="end"> Contact </a> </li>
    	    </ul>
    index.php:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Web Perfect - Home</title>
    <link rel="stylesheet" type="text/css" href="style2.css" />
    </head>
    <body id="home">

    <div id="logo"></div>
        
    <div id="wrapper">
        <div id="header"></div>
        
        <?php include('menu.php'); ?>

    <div id="contentwrap">
            
        <div id="content">
        <h3 class="image">Get a Web Site for Free! <img src="free.jpg" alt="free web design!" /></h3>
        <p> Do you want a web site but you have no money? Web-Perfect will design you a custom page for free! We are offering our design services at no charge because we are a new firm that is currently building a portfolio. <a href="price.htm">Click here</a> for more information.</p>
        </div>
        
        <div id="contenttwo">
        <h3 class="image"> 100% Valid Code! <img src="valid.gif" alt="Valid Code!" /> </h3>
        <p>All sites designed by Web- Perfect are written in validated XHTML and CSS. This creates better visibility of your site by search engines and will help ensure proper display across different browsers. </p>
        </div>
        
    </div>
    </div>

    <div id="footer"><p> Copyright Web-Perfect 2007 </p> </div>

    </body>
    </html>
    Last edited by srule_; 07-14-2007 at 01:12 PM.

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Your menu.php include has extra unneeded coding that is likely causing the issue. Remove the stuff in red, add the stuff in blue.
    Code:
    	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Web Perfect - Home</title>
    <link rel="stylesheet" type="text/css" href="style2.css" />
    </head>
    <body>
       	<ul class="nav">
    	    <li> <a href="index.htm" id="homelink"> Home </a> </li>
    	    <li> <a href="about.htm" id="aboutlink"> About Us </a> </li>
    
    	    <li> <a href="portfolio.htm" id="portfoliolink"> Portfolio </a> </li>
    	    <li> <a href="getasite.htm" id="pricelink"> Get a Site </a> </li>
    	    <li> <a href="contact.htm" id="contactlink" class="end"> Contact </a> </li>
    
    	    </ul>
    </body>
    </html>
    Last edited by _Aerospace_Eng_; 07-14-2007 at 11:34 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    thx, the class"nav" made it work!

    +rep for this help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •