Solved

php include isssue with php 5.2.6

Posted on 2010-11-17
15
393 Views
Last Modified: 2012-05-10
I have done php includes in html pages literally 100's of time on my server with 4.3.9 PHP. I am developing a site  on another server which uses PHP 5.2.6 and when I the same thing it does not work.

I have tried <? include("a_test.php"); ?> and ?php require_once("a_test.php"); ?> neither will work

The include is live at http://kayakfl.com/a_test.php

This is my test page where the include should render http://kayakfl.com/aws.html

I can't change page names to php.

I have both files at root level

I have an added an .htaccess file handler
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

Any thoughts?
0
Comment
Question by:abacus41
  • 5
  • 3
  • 3
  • +2
15 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 200 total points
ID: 34157259
You can't use include function in html page. aws page must be a php page: rename it as aws.php and it will work.

Cheers
0
 

Author Comment

by:abacus41
ID: 34157319
Thanks for the feedback but that is not the case. For example http://www.mandalamedspa.com/index.html - this is how it is coded in Dreamweaver

</head>

<body onload="P7_initPM(0,7,1,0,-1)">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="mainbody">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="858" align="left" valign="top">
                  <?
                              include("includes/header.php");
                  ?>            </td>
      </tr>
      <tr>
        <td align="left" valign="top" class="bodybg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="83" align="left" valign="top">
                  
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                              <td>      
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="left" valign="top">
            <?
                              include("includes/left.php");
            ?>      </td>
  </tr>
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 34157423
aws.html is made with Dreamweaver?
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 3

Expert Comment

by:PorterGraphics
ID: 34157457
Have you confirmed that php does work on this server?
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 34157516
If http://www.mandalamedspa.com/index.html  works, then php works, but I don't understand how it is possible use php code within a html page: Dreamweaver can have something to do with this.
0
 
LVL 3

Assisted Solution

by:PorterGraphics
PorterGraphics earned 100 total points
ID: 34157553
I have used php on an html page before and used Dreamweaver. That's why I thought maybe php wasn't installed on the new server.
0
 
LVL 3

Assisted Solution

by:Prograministrator
Prograministrator earned 100 total points
ID: 34157721
Hello,

edit the main .htaccess file of your site (or create one if not exists),

and just add this line :

addhandler application/x-httpd-php .htm .html 

Open in new window


This line allow parsing php code in .html or htm files.

Good luck.
0
 

Author Comment

by:abacus41
ID: 34158213
Thanks for all the comments:

Yes php works on server, see
http://kayakfl.com/Lido_Accommodations.php

htaccess file in place but I updated to the handler code above

Dreamweaver does not change the code of the incluide.

Yes, aws.html is made in Dreamweaver>
0
 
LVL 3

Expert Comment

by:PorterGraphics
ID: 34158537
When I look at the source of aws.html after the page is loaded, I can see the php code, which makes me believe the problem lies with the server. Have you tried a simple echo command on the aws.html page to see if that code gets processed?
0
 

Author Comment

by:abacus41
ID: 34158810
No, how do I do that?
0
 
LVL 3

Expert Comment

by:Prograministrator
ID: 34158979
@PorterGraphics : that's could be true, but in addition, if the php code can't be parsed correctly in .html files, then php code will be viewable,

@abacus41 :

in .htaccess romove this lines :
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
addhandler application/x-httpd-php .htm .html 

Open in new window


and try to specify that your working with php5 like this :

AddHandler application/x-httpd-php5 .php .htm .html

Open in new window


if it isn't working, try this :

AddHandler x-mapp-php5 .php .htm .html

Open in new window


Usually, that's based on hosting company's servers
0
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 34159190
This from the "aws" page.  It confirms what others have said here: The file was not parsed through PHP.  You may not be able to make changes to .htaccess, but your hosting company can do that for you.  I often let .html files be parsed through PHP.
<!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" />
<title>Untitled Document</title>
</head>

<body>
<p>test page and down below we have the include content</p>
<p>
 

 
 
  
   <?php require_once("a_test.php"); ?>
   
  
</p>
</body>

</html>

Open in new window

0
 

Author Comment

by:abacus41
ID: 34167436
I have gone back to the web hosting company to sort. I will leave the ticket open until I have it sorted and then split up the points as you have all tried hard to help me.

Regards,

David
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 34169834
Good luck with it.  If you find that your hosting company does not immediately understand and fix the issue, you may be in the market for a new hosting company.  I use and am glad to recommend Chihost.com.  Some of my colleagues like Dreamhost, HostGator and SliceHost.
0
 

Author Closing Comment

by:abacus41
ID: 34231489
The issue was at the hosting company and the feedback helped me narrow things down.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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 learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

803 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