include statement not working

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

arun1967
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Mar 29, 2014 11:24 am

include statement not working

Postby arun1967 » Sat Mar 29, 2014 11:51 am

Hi All,

I am very new in php and LAMP environment. I have a index and header file in same directory whic I am trying to render on my apache but my header file does not get ncluded. If I try to put the header code stright in index.php it works.

Seems I am doing some basics wrong. Coudl you pleas ehelp.

Here is my code for index.php:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<title>Impression Coaching</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- START PAGE SOURCE -->
<div class="tail-top-left"></div>
<div class="tail-top">

<?php include 'header.php'; ?>
</div>
<?php
print "<h2>PHP is fun!</h2>";
print "Hello world1!<br>";
print "I'm about to learn PHP!";
?>

</body>
</html>


Also the code for header.php is as follows:

Code: Select all

  <div id="header">
    <div class="row-1">
      <div class="fleft"><a href="#"><img src="images/logo.gif" alt="" /></a></div>
      <div class="fright">
        <ul>
          <li><a href="index.html" class="active">home</a></li>
          <li><a href="about-us.html">about</a></li>
          <li><a href="articles.html">articles</a></li>
          <li><a href="contact-us.html">contacts</a></li>
          <li><a href="sitemap.html">sitemap</a></li>
        </ul>
      </div>
    </div> <!-end of class row-1 -->
    <div class="row-2"><span><b><img src="images/slogan.gif" alt="" /></b> <a href="#"><img src="images/button.gif" alt="" /></a></span></div>
  </div> <!-- end of class header -->


regards,
Arun

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: include statement not working

Postby seandisanti » Sat Mar 29, 2014 6:07 pm

your code looks fine, and works on my side, which makes me think it could be one of two things... either the way you're accessing the file, or an error is preventing access to the include file, like a permission file for example. The former is the most likely. are you trying to open the file directly in your browser, or are you navigating to it on a local or hosted web server? What do you see when you view the page?


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 4 guests