Local server not parsing PHP when in HTML

This is a discussion on Local server not parsing PHP when in HTML within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I've set up Apache, PHP and MySQL on my local PC. The problem I'm having is that ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2005
Greg
 
Posts: n/a
Default Local server not parsing PHP when in HTML


Hello,

I've set up Apache, PHP and MySQL on my local PC. The problem I'm
having is that whenever PHP code is in an HTML file, the local Apache
server is not parsing the PHP code.

I've checked around in the Apache httpd.conf file and can't figure out
what I'm doing wrong.

I'd appreciate any help.


Reply With Quote
  #2 (permalink)  
Old 03-26-2005
Kimmo Laine
 
Posts: n/a
Default Re: Local server not parsing PHP when in HTML

"Greg" <voyagerxv@yahoo.com> kirjoitti
viestissä:km5b41hqivepvpa00llposb42kjo7au4dn@4ax.c om...
>
> Hello,
>
> I've set up Apache, PHP and MySQL on my local PC. The problem I'm
> having is that whenever PHP code is in an HTML file, the local Apache
> server is not parsing the PHP code.
>
> I've checked around in the Apache httpd.conf file and can't figure out
> what I'm doing wrong.
>


Just to make sure: the html files containing php, surely they are not named
..html but .php? If named .html the php parser does not recognize the file as
something that should be executed, it only executes the ones named .php.


Reply With Quote
  #3 (permalink)  
Old 03-26-2005
Yevgen Varavva
 
Posts: n/a
Default Re: Local server not parsing PHP when in HTML

"Greg" <voyagerxv@yahoo.com> ???????/???????? ? ???????? ?????????:
news:km5b41hqivepvpa00llposb42kjo7au4dn@4ax.com...
>
> Hello,
>
> I've set up Apache, PHP and MySQL on my local PC. The problem I'm
> having is that whenever PHP code is in an HTML file, the local Apache
> server is not parsing the PHP code.
>
> I've checked around in the Apache httpd.conf file and can't figure out
> what I'm doing wrong.
>


Try modifying your httpd.conf like this:

Addtype application/x-httpd-php .php .php3

change to

Addtype application/x-httpd-php .php .php3 .htm .html


Reply With Quote
  #4 (permalink)  
Old 03-26-2005
Daedalus
 
Posts: n/a
Default Re: Local server not parsing PHP when in HTML

> Try modifying your httpd.conf like this:
>
> Addtype application/x-httpd-php .php .php3
>
> change to
>
> Addtype application/x-httpd-php .php .php3 .htm .html
>


This is really a bad practice though. This will tell apache to process all
html file with php preprocessor. You should use php extension (php, php3,
phtml...) for file containing php code and leave .html and .htm for plain
html file. It's a completely useless waste of resource to have php
preprocessor to process files that contains no php code. Unless you have no
plain html file, this is not a good way of doing things... and even if you
don't have plain html, this is bad practice anyway... you'll never see that
kind of settings in a good production server so you could face some problem
if you move your sites to another server someday.

Dae



Reply With Quote
  #5 (permalink)  
Old 03-27-2005
Greg
 
Posts: n/a
Default Re: Local server not parsing PHP when in HTML


I performed the steps shown below, and it works.

Here's the story. I took over the site I'm working on from someone
else. He/she must have been using bad practices then.

The PHP code 'snippet' in question is in the index.htm as well as
other html documents. It displays page footers and a navigation menu.

If PHP code shouldn't be in index.htm, I assume then that navigation
menus and page footers would then have to be coded as html, at least
within the index.html file; and that all other files that he/she coded
in which exists PHP code should be renamed as .PHP files. Right?

I thank everyone for their help on this subject.

Greg


On Sat, 26 Mar 2005 15:06:01 -0500, "Daedalus" <daedalus@videotron.ca>
wrote:

>> Try modifying your httpd.conf like this:
>>
>> Addtype application/x-httpd-php .php .php3
>>
>> change to
>>
>> Addtype application/x-httpd-php .php .php3 .htm .html
>>

>
>This is really a bad practice though. This will tell apache to process all
>html file with php preprocessor. You should use php extension (php, php3,
>phtml...) for file containing php code and leave .html and .htm for plain
>html file. It's a completely useless waste of resource to have php
>preprocessor to process files that contains no php code. Unless you have no
>plain html file, this is not a good way of doing things... and even if you
>don't have plain html, this is bad practice anyway... you'll never see that
>kind of settings in a good production server so you could face some problem
>if you move your sites to another server someday.
>
>Dae
>
>


Reply With Quote
  #6 (permalink)  
Old 03-27-2005
Oli Filth
 
Posts: n/a
Default Re: Local server not parsing PHP when in HTML

Greg wrote:
> I performed the steps shown below, and it works.
>
> Here's the story. I took over the site I'm working on from someone
> else. He/she must have been using bad practices then.
>
> The PHP code 'snippet' in question is in the index.htm as well as
> other html documents. It displays page footers and a navigation menu.
>
> If PHP code shouldn't be in index.htm, I assume then that navigation
> menus and page footers would then have to be coded as html, at least
> within the index.html file; and that all other files that he/she coded
> in which exists PHP code should be renamed as .PHP files. Right?
>


Yup, PHP code should live in .php files (along with any inline HTML) for
best practice. If a file is *pure* HTML, then it should be a .htm
(.html) file.

--
Oli
Reply With Quote
  #7 (permalink)  
Old 03-27-2005
Greg
 
Posts: n/a
Default Re: Local server not parsing PHP when in HTML


Thanks everyone. I learned a lot from all of you.

Greg



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:08 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0