Page 1 of 1

Php Code on html pages

Posted: Tue Mar 20, 2012 8:47 am
by alsoto
How do I get my php code to run on html pages without a .php extension? I tried this but it doesn't work:



CODE for index.html

<html><head></head><body>

<?php include("test.php"); ?>

</body></html>

------------------------------------------------------------
test.php in same folder consists of the following text and nothing else: THIS IS DISPLAYING BECAUSE PHP IS WORKING!

------------------------------------------------------------
CODE for .htaccess in same folder:
AddType application/x-httpd-php .html .htm

------------------------------------------------------------
Firefox gives me: Download Error
C:\......Local\Temp\index-11.html could not be opened, beacuase the associated helper application does not exist. Change the association in your preferences.

Internet Explorer just gives me a blank page.


Thanks,
Al

Re: Php Code on html pages

Posted: Tue Mar 20, 2012 9:02 am
by requinix
Just to check the obvious first:

You're running these scripts in Apache, WAMP, or XAMPP? And the URL in the browser starts with "http://"? And the domain name is probably localhost?

Re: Php Code on html pages

Posted: Tue Mar 20, 2012 9:49 am
by alsoto
cPanel Version 11.30.6 (build 4)
Theme x3
Apache version 2.2.22
PHP version 5.2.17
MySQL version 5.1.56
Architecture i686
Operating system linux
Dedicated IP Address 74.53.140.71
Path to sendmail /usr/sbin/sendmail
Path to Perl /usr/bin/perl
Perl version 5.8.8
Kernel version 2.6.38.7
cPanel Pro 1.0 (RC1)


http://www.ams007.com/newimage/index.html

Re: Php Code on html pages

Posted: Tue Mar 20, 2012 10:05 am
by JoeCommodore
You need to set your apache (or other web server) handler to have PHP process the pages with .htm and .html... Something that could be answered with a google search or in the php installation and configuration forum. Though if you plan to distribute your scripts, I would advise not to do that.

Re: Php Code on html pages

Posted: Tue Mar 20, 2012 10:11 am
by alsoto
in cpanel, is it in the section titled "Apache Handlers"?

Re: Php Code on html pages

Posted: Sun Mar 25, 2012 11:03 am
by irony09
If all else fails or you are in a hurry, you could always use an iframe!