PHP mysterious problem

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
fearlesss
Forum Newbie
Posts: 4
Joined: Mon Mar 03, 2008 5:59 pm

PHP mysterious problem

Post by fearlesss »

Hi,

Sorry my first post is a question , rather than an answer but I don't really know
much about php ill be honest.

Ok I have 2 websites running the exact same pages but on different servers
one works one doesn't

http://www.biddingbuzz.com.au/index.html

This is the page and at the bottom is a php script

<?php
include("footer.html");
?>

The other page is the same html file with the same script

http://www.youwonthebid.com/index.html


Now I've been told you cant run php in a html file without changing the extention to .php
but for some reason on the bidding buzz site the php works ?
I cannot figure out how on earth how it works im sure its something to do with the hosting

bidding buzz host runs PHP Version 4.4.4


youwonthe bid host runs PHP Version 4.3.11

Can anyone explain whats going on here
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP mysterious problem

Post by Christopher »

I would guess that the first server has PHP parsing .html files and the second does not. Change the name of the script on the second server that does not work to:

http://www.youwonthebid.com/index.php

Just using the domain name http://www.youwonthebid.com should still work fine with either extension.
(#10850)
fearlesss
Forum Newbie
Posts: 4
Joined: Mon Mar 03, 2008 5:59 pm

Re: PHP mysterious problem

Post by fearlesss »

Thanks for that.

Is their anyway i can get php phrasing to work on the other server ?

I was really hoping to get it to work on both servers so i don't have to change
each file to .php as throught the site their are hundreds of pages :(

regards
josh,
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: PHP mysterious problem

Post by Christopher »

For Apache, you can add "index.html" to the DirectoryIndex setting for the webserver either in the configuration file or .htaccess.
(#10850)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: PHP mysterious problem

Post by Benjamin »

arborint wrote:For Apache, you can add "index.html" to the DirectoryIndex setting for the webserver either in the configuration file or .htaccess.
You must be tired. I think you meant "AddType application/x-httpd-php .php .htm .html"
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP mysterious problem

Post by Chris Corbyn »

The technical term for "mysterious problem" is actually "voodoo" ;) I'll be enforcing this more strictly in future.
fearlesss
Forum Newbie
Posts: 4
Joined: Mon Mar 03, 2008 5:59 pm

Re: PHP mysterious problem

Post by fearlesss »

Well I should have just kept my mouth shut :(

This morning I checked both websites and neither of them have the php script working now :(
I jinx'd it .

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

I added this to both htaccess pages on both websites and it basically killed both websites
it couldnt find index.html and came up with a whole bunch of errors ?
was their something missing I didn't do ?

it really is a voodoo problem now .

I guess i'm just going to have to bite the bullet and take a whole day out changing each page
to .php :(


UPDATE !!

Ok stop looking guys :)

I changed the script to
AddHandler application/x-httpd-php .html .htm

And now php works on both sites !

For anyone else having problems with running php on html files heres what i came across

By default most web servers across the internet are configured to treat as PHP files only files that end with .php. In case you need to have your HTML files parsed as PHP (e.g .html) or even if you want to take it further and make your PHP files look like ASP, you can do the following:

For web servers using PHP as apache module:

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

For web servers running PHP as CGI:

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

In case you wish to do the ASP mimick:

For PHP as module:

AddType application/x-httpd-php .asp

OR

For PHP as CGI:

AddHandler application/x-httpd-php .asp


thanks guys
Last edited by fearlesss on Wed Mar 05, 2008 10:44 pm, edited 1 time in total.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: PHP mysterious problem

Post by Ambush Commander »

it couldnt find index.html and came up with a whole bunch of errors ?
Was it a 500 internal server error?

It's a good practice, anyway, to keep your PHP files labeled php. Having them as html is slightly voodoo-y; however, AddType should work.
fearlesss
Forum Newbie
Posts: 4
Joined: Mon Mar 03, 2008 5:59 pm

Re: PHP mysterious problem

Post by fearlesss »

it was a 500 error

Yeah I know, I've only just taken over working on the site and it needs alot of work.
But ild rather have a temporary fix for the mean time.
Then later on when I've got nothing to do ill start the process of changing all the pages to .php
Post Reply