Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Noob php include problem

Posted on 2008-10-31
13
Medium Priority
?
344 Views
Last Modified: 2013-12-13
Hello,

After finally getting MAMP working on my mac I am trying to get a php include menu into my div layout. This is my first attempt at any php. It is stopping any of my other divs displaying and not displaying the menu!

I have attached both pages as code, first is index.php, second is menu.php. Any help would be great.
<!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=UTF-8" />
<link rel="icon" 
      type="image/ico" 
      href="http://www.willsavage.com/_sites/EP/images/EP.ico">
<title>EVENT PARAMEDICS</title>
<link href="epdesign.css" rel="stylesheet" type="text/css" />
<link href="menuh2.css" rel="stylesheet" type="text/css" />
<!--[if lt IE 7]>
<style type="text/css" media="screen">
#menuh{float:none;}
body{behavior:url(csshover.htc); font-size:100%;}
#menuh ul li{float:left; width: 100%;}
#menuh a{height:1%;font:bold 0.7em/1.4em arial, sans-serif;}
</style>
<![endif]-->
</head>
<body>
<p>&nbsp;</p>
<div class="container">
  <div class="header"></div>
  
  <div class="menu" id="menuframe">
    <div id="menuh">
	
    <?php include("menu.php"); ?>
    
    
	</div>
   </div> 
 
 
 
  <div class="imageheader"></div>
  <div class="contentContainer">
    <div class="right_content">
      <h3>Latest News</h3>
      <p>&nbsp;</p>
      <div class="news_list">
        <h4>New Website Now Live<br />
          01.01.09</h4>
        <p align="left">Any returning visitors will notice that we have just launched our brand new <br />
          <a href="#"></a></p>
      </div>
      <div class="read_more">
        <div align="right">
          <p><a href="latest-news.html" target="_self">read more</a></p>
        </div>
      </div>
      <div class="news_list">
        <h4>New Job Vacancies<br />
          10.11.08</h4>
        <p>Due to us taking on a new NHS 999<a href="#"></a> contract for the southcoast, we are <br />
        </p>
      </div>
      <div class="read_more">
        <div align="right">
          <p><a href="latest-news2.html" target="_self">read more</a></p>
        </div>
      </div>
      <div class="news_list">
        <h4>NHS 999 Contract Extended<br />
          10.11.08</h4>
        <p>We a happy to say that our existing contract to provide emergency </p>
      </div>
      <div class="read_more">
        <div align="right">
          <p><a href="latest-news3.html" target="_self">read more</a></p>
        </div>
      </div>
      <div class="news_list">
        <h4>NHS 999 Contract Extended<br />
          10.11.08</h4>
        <p>We a happy to say that our existing contract to provide emergency </p>
      </div>
      <div class="read_more">
        <div align="right">
          <p><a href="latest-news4.html" target="_self">read more</a></p>
        </div>
      </div>
      <div class="more_news">
        <div align="right">
          <p>&nbsp;</p>
          <p align="center"><a href="latest-news.html" target="_self">See more LATEST NEWS</a></p>
        </div>
      </div>
    </div>
    <div class="main_text" id="main_text">
      <h1>Welcome to Event Paramedics Ltd.</h1>
      <h2>&nbsp;</h2>
      <h2>First Aid, Registered Emergency Medical Technicians, Nurses, Paramedics, Doctors, Emergency Vehicles &amp; Services.</h2>
      <p>&nbsp;</p>
      <p>Event paramedics was established in blar by Rick Player to offer advanced emergency medical cover for all events sksb aphjksb dlksbhldbjlanjf.</p>
      <p>&nbsp;</p>
      <p>In more recent years much of our time has been taken up serving more and more Emergency 999 NHS contracts for the south coast.</p>
      <p>&nbsp;</p>
      <p>More info that warrents being on the very first page. All of the content from the front page of the original site will be buried in our services so it is only around for the people who want to see it! This is just a block as a breif introduction to your company.</p>
    </div>
    <div class="quick_links">
      <div id="quick_links_1">
        <h3>Quick Links...</h3>
        <p>&nbsp;</p>
        <p><a href="#">Training</a></p>
        <p><a href="#">Latest News</a></p>
        <p><a href="#">Staff Profiles</a></p>
        <p><a href="#">Testimonials</a></p>
        <p><a href="#">Contact Us</a></p>
      </div>
      <div id="quick_links_2"><a href="#"><img src="images/quick_links/images/event-link.jpg" width="125" height="125" /></a></div>
      <div id="quick_links_3"><a href="#"><img src="images/quick_links/images/jobs-link.jpg" width="125" height="125" /></a></div>
      <div id="quick_links_4"><a href="#"><img src="images/quick_links/images/nhs-link.jpg" width="125" height="125" /></a></div>
    </div>
    <div style="clear:both;"></div>
  </div>
  <div class="footer"></div>
</div>
 
</body>
</html>
 
 
 
 
 
 
 
 
<?php 
 
 
      <ul>
       <li><a href="index.html" target="_self" class="top_parent">About EP</a>
          <ul>
            <li><a href="index.html" target="_self" class="drops">Homepage</a></li>
            <li><a href="latest-news.html" target="_self" class="drops">Latest News</a></li>
            <li><a href="history.html" target="_self" class="drops">A Brief History</a></li>
            <li><a href="our-staff.html" target="_self" class="drops">Our Staff</a></li>
          </ul>
        </li>
      </ul>
      <ul>
        <li><a href="OS_overview.html" target="_self" class="top_parent">Our Services</a>
          <ul>
            <li><a href="OS_overview.html" target="_self" class="drops">Overview</a></li>
            <li><a href="OS_events.html" target="_self" class="drops">Event Cover</a></li>
            <li><a href="OS_transport.html" target="_self" class="drops">Patient Transport</a></li>
            <li><a href="OS_NHS.html" target="_self" class="drops">NHS contracts</a></li>
            <li><a href="OS_training.html" target="_self" class="drops">Training</a></li>
            <li><a href="OS_other.html" target="_self" class="drops">Other Services</a></li>
          </ul>
        </li>
      </ul>
      <ul>
        <li><a href="VC_clients.html" target="_self" class="top_parent">Valued Clients</a>
          <ul>
            <li><a href="VC_clients.html" target="_self" class="drops">Links to Clients</a></li>
            <li><a href="VC_testimonials.html" target="_self" class="drops">Testimonials</a></li>
          </ul>
        </li>
      </ul>
      <ul>
        <li><a href="Careers_vacancies.html" target="_self" class="top_parent">Careers</a>
          <ul>
            <li><a href="Careers_vacancies.html" target="_self" class="drops">Current Vacancies</a></li>
            <li><a href="Careers_cvs.html" target="_self" class="drops">Send us your CV</a></li>
          </ul>
        </li>
      </ul>
      <ul>
        <li><a href="Staff_login.html" target="_self" class="top_parent">Staff Login</a></li>
      </ul>
      <ul>
        <li><a href="EP_sitemap.html" target="_self" class="top_parent">Site Map</a></li>
      </ul>
      <ul>
        <li><a href="EP_contact.html" target="_self" class="top_parent">Contact Us</a></li>
      </ul>
 
 
 
?>

Open in new window

0
Comment
Question by:willsavage
  • 7
  • 3
  • 2
  • +1
13 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 600 total points
ID: 22854144
you probably have the wrong path. Assuming your file is at:
http://www.yoursite.com/menu.php

Try:
    <?php require_once( $_SERVER['DOCUMENT_ROOT'] ."/menu.php"); ?>
0
 

Author Comment

by:willsavage
ID: 22854199
the site is running on a MAMP testing server on my mac, and sorry but I am completely new to all of this.

Both files are running from the htdocs folder within mamp which is my root i believe.

http://localhost:8888/index.php
http://localhost:8888/menu.php


0
 

Author Comment

by:willsavage
ID: 22854216
And I have this all set up in Dreamweaver CS3. I hope this helps.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 600 total points
ID: 22854233
Change your include statement like this so you can learn more about the errors...

<?php error_reporting(E_ALL); require(menu.php); ?>

Tell us what you get from that.  If you do not get a PHP error, do a "view source" on the rendered HTML.

Best regards, ~Ray
0
 
LVL 82

Expert Comment

by:hielo
ID: 22854243
did you try replacing:
<?php include("menu.php"); ?>

with what I posted earlier? If not, do so. If yes, do you get any errors?
0
 

Author Comment

by:willsavage
ID: 22854289
Sorry, yes i did and it didn't change anything. Still wasn't displaying the divs below the include, or the menu. I have come some way towards solving it now by changing the code of menu.php.

I took out the <?php ?>

and replaced it with just

<html>
<body>
then my menu code

This is almost working, the problem now is that it is not picking up my CSS. Sorry to change the question but where would I need to put my stylesheet link? I have a seperate stylesheet for the menu and rest of the site.


0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 22854309
You would probably want to put your style sheet links near these statements:

<link href="epdesign.css" rel="stylesheet" type="text/css" />
<link href="menuh2.css" rel="stylesheet" type="text/css" />
0
 

Author Comment

by:willsavage
ID: 22854356
Sorry for being such a noob at this Ray, regarding the error log, I did as you said and it didn't say there were errors (or I'm just not looking in the right place)  but the source just shows up to and not including the php include and none of the divs below.

I do think I have almost sorted it though as it is displaying properly now i made the changes above to menu.php.

As for the styling, they were what I was refering to as my stylesheet links! They are both in index.php
<link href="epdesign.css" rel="stylesheet" type="text/css" />
<link href="menuh2.css" rel="stylesheet" type="text/css" />

When the site was a single html file with menu code in index.html...
epdesign.css styled whole site
menuh2.css styled the menu

Now that the menu is as an include, it no longer picks up the styling. Do I need to move <link href="menuh2.css" rel="stylesheet" type="text/css" /> in menu.php somehow.

Sorry if I am not being clear.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22854387
>>but the source just shows up to and not including
What is in your include file.most likely you have errors in it.
0
 

Author Comment

by:willsavage
ID: 22854684
I have been tinkering with this and I seem to have got it working now. Not quite sure how or why!

The only thing I changed was putting the div codes into my menu.php file instead of the index.php.

  <div class="menu" id="menuframe">
    <div id="menuh">

Menu Content here

</div>
</div>

Before my include was just the menu content, and the div classes were left in the index file.

Thanks for all your help and sorry for wasting your time.
0
 

Author Comment

by:willsavage
ID: 22854702
Can someone please tell me the best practice here? Do I accept my own solution or can I close this thread off some other way?
0
 
LVL 20

Assisted Solution

by:NerdsOfTech
NerdsOfTech earned 300 total points
ID: 22856282
Best practice is to split the points up amongst contributors I believe
0
 

Author Closing Comment

by:willsavage
ID: 31512209
Thanks again
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
This article outlines the struggles that Macs encounter in Windows-dominated workplace environments – and what Mac users can do to improve their network connectivity and remain productive.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question