Forum Moderators: open

Message Too Old, No Replies

PHP scripts on html pages?

         

henjon

9:37 am on Sep 25, 2006 (gmt 0)

10+ Year Member



Hi, just got me a add comment script, that i wish to use at my html site. as and add comment to article tool. It says that i simply need to add a small portion of code on the pages that needs the comment function and the instal the script on the server, in i would be good to go.. My question is... will it work, since the entire site is not PHP.?

ASchmitt

9:41 am on Sep 25, 2006 (gmt 0)

10+ Year Member



you cannot use php on a page with html ext. You simply can not! :-)

Try to change all your pages to php... thay will react on the same way as your html pages do...

to include a script file try

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

[edited by: ASchmitt at 9:41 am (utc) on Sep. 25, 2006]

benevolent001

9:41 am on Sep 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



am not sure

There is some setting like what type of pages would be pages would be processed by php engine , just check in php.ini file , there is some setting for this.

may be someone else would give you great idea and insight over this , but above would keep you busy

penders

10:07 am on Sep 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you cannot use php on a page with html ext. You simply can not! :-)

Not strictly true, although for most people it is I guess. Like benevolent001 says, I believe you can get your web server to parse any file you like for PHP code - it is a web server setting (Apache). However, you need to add things (AddType...?) to your servers httpd.conf (Apache) file - but for people on shared hosting you probably don't have access to it.

encyclo

10:14 am on Sep 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you cannot use php on a page with html ext. You simply can not!

On the contrary, you most certainly can! :) In fact you only can if you are on a shared server running Apache and you can use a .htaccess file, or if you are on a dedicated server where you can directly adjust the configuration.

The basic .htaccess syntax for parsing all .html files for PHP is:

AddHandler application/x-httpd-php .html

If you only want to make one file parsed for PHP, you can also specify it:

<Files myphppage.html>
ForceType application/x-httpd-php
</Files>

This is placed in your .htaccess file in the document root. If you don't already have a .htaccess file, you can create a blank text file.

penders

10:34 am on Sep 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks encyclo, for clearing that one up!

benevolent001

3:12 pm on Sep 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



:) am glad my that my memory cant be so poor , i read it somewhere that it can be done