Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


getting a php include statement to work in an html document enabled for php

Posted on 2011-03-04
Medium Priority
Last Modified: 2012-06-27

This page is a template for a site (eventually to be coded in css rather than what it is now).  We did not want to lose page rankings so it is set up to remain .html while including some php code:


The print statements work just fine, however there is an include statement that follows the "hello" and it doesn't work.  If I go straight to the file, it does as it should:  http://www.whitelotus.org/includes/test.php

about Test.html code:

<!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"><!-- InstanceBegin template="/Templates/expand_menu.dwt" codeOutsideHTMLIsLocked="false" -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>White Lotus</title>
<!-- InstanceEndEditable -->
<link href="css/global.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript" src="js/swap.js"></script>
<script language="JavaScript" src="mm_menu.js"></script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->

<body onload="MM_preloadImages('images/registration2.gif','images/site_map2.gif')">
<table width="967" border="0" align="center" cellpadding="0" cellspacing="0">
    <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <td align="center" valign="top"><img src="images/header1.gif" alt="Yoga Banner" width="322" height="105" /></td>
        <td align="center" valign="top"><img src="images/header2.gif" alt="Yoga Banner" width="323" height="105" /></td>
        <td align="center" valign="top"><img src="images/logo.gif" alt="Yoga Banner" width="322" height="105" border="0" usemap="#Map" /></td>
        <td align="center" valign="top"><img src="images/top_bar1.gif" alt="Yoga Banner" width="322" height="66" /></td>
        <td align="center" valign="top"><img src="images/top_bar2.gif" alt="Yoga Banner" width="323" height="66" /></td>
        <td align="center" valign="top"><img src="images/top_bar3.gif" alt="Yoga Banner" width="322" height="66" /></td>
    <td align="center" valign="top" background="images/background.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <td width="250" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr valign="top">
                    <td width="23" align="left" style="background: url(images/menu_L_bg.gif) right top repeat-y;"><img src="images/menu_L.gif" width="23" height="434" /></td>  <td align="left"><!-- InstanceBeginEditable name="menu" -->
					<?PHP print "hello"; include("/includes/test.php"); ?><!-- InstanceEndEditable --></td>
              <td align="left" valign="top" style="background:url(file:///C|/Documents%20and%20Settings/Em/My%20Documents/Websites/wlf/images/menu_B2.gif) right top no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <td align="right" valign="top">&nbsp;</td>
                  <td align="left" valign="top"><img src="images/headings/newsletter.gif" width="116" height="20" style="margin-left:28px;" /></td>
                  <td align="right" valign="top"><table width="88%" border="0" cellspacing="0" cellpadding="0">
                      <td height="25" align="left" valign="top" class="bodytext">Receive our eNews<br />
                        and a complimentary<br />
                        <em>Principles of Yoga</em> article.
                      <td align="left" valign="top"><form method="post" action="epsmail.php" id=form1 name=form1>
 <input type="hidden" name="owner_id_enc" value="05948c-938328ac" />
<input type="hidden" name="function" value="Subscribe" />   

<input name="user_email" type="text" class="input" value="Enter Your Email Here" onfocus="javascript:if(this.value=='Enter Your Email Here'){this.value=''}" onBlur="if(this.value==''){this.value='Enter Your Email Here'}" style="height:20px; width:160px; margin:0;"/>
 <br />
 <input name="user_zip" type="text" class="input" value="Enter Your Zip Code Here" onfocus="javascript:if(this.value=='Enter Your Zip Code Here'){this.value=''}" onBlur="if(this.value==''){this.value='Enter Your Zip Code Here'}" style="height:20px; width:160px; margin:3px 0;"/> <input name="Submit2" type="submit" class="button" value="&raquo;" style="height:24px;" />
                      <td height="10" align="left" valign="top"></td>
                    <!--    <tr>
                <td align="left" valign="top" class="bodytext"><a href="http://www.mailermailer.com/" target="_blank">MailerMailer.com</a> &ndash; check for an API</td>
              </tr> -->
          <td align="left" valign="top"> 
            <!-- start indexing here -->
            <!-- InstanceBeginEditable name="master" -->Content will go here.<!-- InstanceEndEditable --> 
            <!-- stop indexing here -->
    <td align="center" valign="top"><img src="images/footer_T.gif" width="967" height="38" /></td>
    <td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <td width="250" align="left" valign="middle"><img src="images/footer_L.gif" width="250" height="36" /></td>
        <td align="left" valign="middle" background="images/footer.gif" class="footer">2500 San Marcos Pass &bull; Santa Barbara, CA 93105<br />
          Tel: 805-964-1944 &bull; Fax: 805-964-9617 &bull; eMail:
          <!-- This script can be used FREELY as long as this copyright message is intact: Mail Spam Blocker / Copyright (c) 2004 by www.myvasco.com Internet Marketing Solutions -->
          <a href="mailto:info@whitelotus.org" style="color:#e6f1ad;">&#105;&#110;&#x66;&#x6f;&#x40;&#x77;&#x68;&#x69;&#x74;&#101;&#x6c;&#x6f;&#x74;&#x75;&#x73;&#x2e;&#x6f;rg</a></td>
        <td width="210" align="left" valign="middle" background="images/footer.gif" class="footer">&copy;
          <script language="JavaScript" type="text/javascript">
    today=new Date();
          White Lotus Foundation. <br />
          All Rights Reserved. </td>
        <td width="18" align="left" valign="middle"><img src="images/copyright.gif" width="18" height="36" /></td>
    <td align="center" valign="top"><img src="images/footer_B.gif" width="967" height="28" /></td>
    <td align="center" valign="top" class="footertext">White Lotus Foundation holds Yoga teacher training courses four times per year in Santa Barbara, CA at our beautiful retreat center in the mountains. Students attend from around the country to receive their yoga certification. For in-depth information on our <a href="teacher_training.html">Yoga Certification</a> Program, click Yoga Certification. Our courses are renowned around the world for their comprehensive content, individual attention to each student, and for the wonderful <br />
      transformational experience of studying with yoga pioneers and best selling authors, Ganga White and Tracey Rich. <br />
      White Lotus<sup class="tm">TM</sup> offered the first yoga teacher training and certification in America in 1968.<br />
      <p class="footertext" style="color:#000000; margin-top:8px;"><a href="http://www.ndic.com" target="_blank">Web design &amp; development by NDIC</a>, designed in collaboration with Tracey Rich.</p></td>

<map name="Map" id="Map"><area shape="rect" coords="88,22,293,93" href="index.html" />
</map><script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-5159729-6");
} catch(err) {}</script> 
<!-- InstanceEnd --></html>

Open in new window

Question by:emilysbca
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 84

Accepted Solution

Dave Baldwin earned 2000 total points
ID: 35041319
Try removing the '/' before 'includes' and the '()'.  http://us3.php.net/manual/en/function.include.php
include "includes/test.php";

Open in new window


Expert Comment

ID: 35041586
Few ideas:

How about a meta refresh to a php page ?
would that work for the page ranking ?

Frame page ? (one frame being 100% by 100%, loading a php page)

create 1 gigantic div, and have javascript fill it with the html-output from a php page

What you also could do is instead of including a .js file
make it include to a .php:
<script type="text/JavaScript" src="js/variables.php"></script>

then ur php page, can do all the mojo u want, as long as you output variables via javascript again.
Example of the php file:


$bla = "w00t";

echo "var bla = '".$bla.';\n";

Header("content-type: application/x-javascript");


on the server, make edit the html MIME part to read PHP as well.

10yrs ago I managed to include html files in a html file, playing with templates top and bottom, but I forgot how, let alone if it wasn't a IE 5 and lower only thing ;P
LVL 17

Expert Comment

ID: 35043208
To include PHP code in a .html file you will need to override the default handling by editing the .htaccess file with something like:

RemoveHandler .html
AddType application/x-httpd-php .php .html

But, if you're going to be playing with .htaccess then you might as well just make it cleaner with a nice rewrite rule so the world sees .html, but you get to be .php on your side.  You can read more about that here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

On a side note, the php open tag should be <?php not <?PHP.

Author Closing Comment

ID: 35048343
Yes!!!!  Thank you!  I'm so glad it was that easy...
LVL 84

Expert Comment

by:Dave Baldwin
ID: 35048919
You're welcome and thanks for the points.

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

636 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