Page 1 of 1

PHP not processed [SOLVED]

Posted: Sat Feb 14, 2004 2:54 pm
by Threetwosevensixseven
I've set up PHP 4.2.2 and Apache 1.3.29 (the versions my host uses) on XP Home. Seems a standard installation except I put PHP in c:\program files\php. Running the Apache php module.

The problem is my php scripts don't get processed, even in the simplest hello world script. If I view source in my browser I see the php tags.

But phpinfo() is running ok and gives me sensible values.

From httpd.conf:

Code: Select all

ScriptAlias /php/ "C:/Program Files/PHP/"
LoadModule php4_module "C:/Program Files/PHP/sapi/php4apache.dll"
Action application/x-httpd-php /php/php.exe
AddType application/x-httpd-php .php 
DocumentRoot "E:/Homepage/v2/Root/"
ServerName 127.0.0.1
From php.ini:

Code: Select all

error_reporting  =  E_ALL
display_errors = on
display_startup_errors = on
doc_root = "E:/Homepage/v2/Root/"
I've only just started learning so I'm sure I've made an obvious mistake, but nothing I've read or tried seems to be the cause. Would be grateful for some suggestions :)

Posted: Sat Feb 14, 2004 4:48 pm
by DuFF
What directory are you putting the scripts in?

According to your httpd.conf it should be in "E:/Homepage/v2/Root/" I think.

Posted: Sat Feb 14, 2004 5:26 pm
by Threetwosevensixseven
Oh, I just figured it. The scripts that weren't working mixed html and php together, but had an .html extension. If I rename them to a .php extension then the php runs.

Er, is there a way to embed php in .html files and still have it run, or do I need to rename all my files?

Sorry for stating the problem in a misleading way...

Posted: Sat Feb 14, 2004 5:38 pm
by DuFF
This line in httpd.conf:

Code: Select all

AddType application/x-httpd-php .php
tells Apache to process any file ending in ".php" as application/x-httpd-php. So, all you have to do is add another line in there, such as:

Code: Select all

AddType application/x-httpd-php .htm .html
More information at http://www.php.net/manual/en/security.hiding.php

And remember:
php.net wrote: Or hide it as HTML code, which has a slight performance hit because all HTML will be parsed through the PHP engine
It would be better in the long run to rename all the files.

Posted: Sat Feb 14, 2004 5:43 pm
by Threetwosevensixseven
Thank you.

I feel especially dumb now as I quoted that line myself :)

Cheers