Category Archives: add-type

PHP in body of html not rendering

Hostgator have changed their server config recently for shared accounts. The result of which is that where html files were previously serving php now they are not. The output includes php tags showing in the source, and of course it is not rendered.

They wont help, telling me its a coding issue. Which I don't believe...

<?php echo 'test'; ?>

doesn't work.

So I can change all the html files and internal links to have php file extensions but this is tedious work. Luckily if I am forced to it is a small site.

However if I add an .htaccess instead with:

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

this should cut it right?

I then get the request throwing an open file dialog on firefox, and just still not rendering on IE... (I'm getting the error: You have chosen to open...which is: application/x-httpd-php)

Any thoughts appreciated.

PHP in body of html not rendering

Hostgator have changed their server config recently for shared accounts. The result of which is that where html files were previously serving php now they are not. The output includes php tags showing in the source, and of course it is not rendered.

They wont help, telling me its a coding issue. Which I don't believe...

<?php echo 'test'; ?>

doesn't work.

So I can change all the html files and internal links to have php file extensions but this is tedious work. Luckily if I am forced to it is a small site.

However if I add an .htaccess instead with:

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

this should cut it right?

I then get the request throwing an open file dialog on firefox, and just still not rendering on IE... (I'm getting the error: You have chosen to open...which is: application/x-httpd-php)

Any thoughts appreciated.

Why is php script not working in my html file? [on hold]

I have written a php script which fetches data from database. Now I want to display this data on an html page.

The problem is that php script does not work when I include it in an html page. Running the script in a php file works fine.

I tried displaying a simple line in php in html page but no results. Here is the code:

<html>
<head>
</head>
<body>  
<?php
$color = "red";
echo "Roses are $color";
?>
</body>
</html>

I am running PHP Version 5.3.28 on Apache server on bigrock hosting.

I tried adding : AddType application/x-httpd-php5 .html .htm line to .htaccess file but doing that causes the page to download when accessing the url.

I checked a Similar thread for the problem and changed my .htaccess file to the below but the download prompt still persists.

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

AddType application/x-httpd-php5 .htm .html

Next, I changed the .htaccess file to the below :

AddHandler x-httpd-php5-3 .php

AddHandler application/x-httpd-php5 .php

After changing, the download prompt is not coming, but still the php script is not getting executed.

Any help would be appreciated. Thanks in advance.