jonbras Posted August 27, 2014 Share Posted August 27, 2014 (edited) 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 August 27, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted August 27, 2014 Share Posted August 27, 2014 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. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted August 27, 2014 Share Posted August 27, 2014 PHP tip: There is no need to repeat the php tags for multiple lines of code. Wax on (code)(code) Wax off. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.