PDA

View Full Version : php in html - problem



greenbarbi
03-10-2009, 12:25 PM
Hi,

I have a website which runs primarily on html, but I call some dynamic content using <?php include 'list.php' ?> inside the body tag of index.html.

<html>
....
<body>
....
<?php include 'list.php' ; ?>
...
</body>
</html>

The domain is redirected to public_html/myproject (index.html and list.php is present here). Now only the html shows up. The php content is not included. (the list does not show up, works fine in local machine) How do I include php on html files?

What changes should I make?
1. I tried adding a .htaccess in the myproject folder with the content

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

But it throws a 500 error.

2. Should I make any changes to php.ini file? [ There is no php.ini file in the sub directory as of now. Is it required? ]

3. I also tried adding a apache handler in the bluehost control panel, but in vain.

Desperately in need of a solution. Appreciate any quick response, Thanks
Barbi

charlesp
03-10-2009, 11:30 PM
Do you have a link to your web page?

wysiwyg
03-11-2009, 01:34 AM
Actually you just need
AddHandler application/x-httpd-php5 .php .html

AddType tells the browser what mime type to use (although it wouldn't cause a 500 error).

The php.ini file is only for overriding default settings, it isn't necessary.

felgall
03-11-2009, 02:11 PM
AddType tells the browser what mime type to use

That line is the one that tells it to use PHP 5 instead of PHP 4 and you want it to do that for .html files as well as for .php files.

wysiwyg
03-11-2009, 02:28 PM
AddHandler tells the server how to handle the extension, AddType tells the browser what type of file it is.

The browser is expecting the page to be html, not php.

php8ox
03-15-2009, 03:08 PM
just remember that any short tags <? without <?php or <?xml will be parsed as php, not xml or other code types.

modifications to your php.ini file will affect all running code or applications on your part of the server. The further you get from normal, the more likely something, somewhere else, will not run like you expect.

adding the previously suggested code in the subdirectory you are needing changed -> .htaccess file is the best approach.

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

even more specific .htaccess modification?
<Location /home/username/public_html/index.html>
AddType application/x-httpd-php .html
</Location>