...

View Full Version : Include Function with Nav



srule_
07-14-2007, 05:24 AM
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 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

Fumigator
07-14-2007, 05:47 AM
Did you put menu.php in a directory called "includes" or is it in the same directory as index.php?

srule_
07-14-2007, 01:02 PM
it is in the same directory as index

srule_
07-14-2007, 01:05 PM
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:


<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:


<!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>

_Aerospace_Eng_
07-14-2007, 11:29 PM
Your menu.php include has extra unneeded coding that is likely causing the issue. Remove the stuff in red, add the stuff in blue.

<!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>

srule_
07-15-2007, 05:56 AM
thx, the class"nav" made it work!

+rep for this help :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum