Solved

php include isssue with php 5.2.6

Posted on 2010-11-17
15
369 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 30

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 30

Expert Comment

by:Marco Gasi
ID: 34157423
aws.html is made with Dreamweaver?
0
 
LVL 3

Expert Comment

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

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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 108

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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now