PHP not processed [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Threetwosevensixseven
Forum Newbie
Posts: 3
Joined: Sat Feb 14, 2004 2:54 pm

PHP not processed [SOLVED]

Post 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 :)
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
Threetwosevensixseven
Forum Newbie
Posts: 3
Joined: Sat Feb 14, 2004 2:54 pm

Post 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...
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post 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.
Threetwosevensixseven
Forum Newbie
Posts: 3
Joined: Sat Feb 14, 2004 2:54 pm

Post by Threetwosevensixseven »

Thank you.

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

Cheers
Post Reply