?
Solved

php include isssue with php 5.2.6

Posted on 2010-11-17
15
Medium Priority
?
427 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 800 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 400 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 400 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 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 400 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 111

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month15 days, 22 hours left to enroll

850 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