Jump to content

Recommended Posts

I need some help with this. I created an index.php page and I inserted an include statement that referred to a header.html page. It works when working it in MS Webmatrix but when I put it on my server I only get my index.php page. My include statement will not get the header.html page. What am I doing wrong?  I also tried changing all of my files to .php extensions also and still the same.

Here is my index.php file:
 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Braswell Electric</title>
<link rel="stylesheet" href="braswellelectric.css">
</head>

<body>
<div>
<?php include('/includes/header.html');?>
<?php include('/includes/aside.html');?>

<article class="About">
<header class="AboutHeader">
<h2>About Us</h2>
</header>
<p><b>Braswell Electric</b> is a family business owned and operated by Jim and Joyce Braswell located in Sylacauga, Alabama. Braswell Electris has been in business in Sylacauga for 25 years and covers the greater Talladega County area. We do new homes, remodels, or any small electrical issues you may have. We are licensed and insured and we are here for your residential needs.</p>

<img src="pics/Coach Light.jpg" alt="Coach Light" >
<img src="pics/Outside Plug.jpg" alt="Outside Plug">
<img src="pics/Service.jpg" alt="Service">

</article>
</div>
</body>
</html>

Here is my header.html file

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>

</head>
<body>
<header class="Header">
<h1 style="display: none">Braswell Electric</h1>
<img src="pics/lightning1.jpg" alt="Header Pic">
</header>

</body>
</html>
Edited by Ch0cu3r

Most likely due to starting your include file paths with a forward slash /

 

In PHP / means the root of the file system, not root of your website.

 

Either remove the forward slash from the start of the include path or prepend $_SERVER['DOCUMENT_ROOT'] to the file paths, example

<?php include($_SERVER['DOCUMENT_ROOT'] .'/includes/header.html');?>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/aside.html');?>

Also when posting code please wrap it within


tags. For now I have edited your post for you.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.