php not running in html page
Hi group,
I have an HTML page that I want to run some PHP code. I found several "How tos" about this but I can't get it to work. The code is very simple: Code:
cat test.html Thanks for your time. |
Did you enable/set up php in apache?
|
Code:
sudo yum install php Code:
sudo apt-get install php |
Once you have apache set up correctly you need to access the page through apache. So don't try to view the page directly in your web browser but access through a proper URL which will make the web service (apache) serve up the page after having processed the php.
|
Usually Apache does not put files through the php interpreter unless they have the .php extension.
It is, however, possible to make Apache run .html files. |
Quote:
Code:
Installed Packages |
Quote:
Code:
AddType application/x-httpd-php .php |
I was also facing a similar problem, see this.
|
I just wonder why you use .html extension. I am used to use .php for php code, and I am not sure if php can run in .html file (be parsed). Never the less if you want to use .html file you can include it from .php script. Sense? You can just click on .html file to see the html formatting in browser (If you want to see formatting of page).
|
[Solved] Needed to add AddType to php.conf
Quote:
Code:
AddType application/x-httpd-php .php .html |
Have you tried saving your html file as .shtml and saving the php component as a .php file then using an SSI to include the .php into the .shtml?
Editing php.conf to get php to run in html files doesn't work on all servers; but php will usually run in an shtml file as an SSI. |
Quote:
Whether the extension is html or php, the file contents should be identical. |
Quote:
|
I too use the .html extension like you've showed, should be no probs there...
Have done as graemef said: Quote:
After installing server etc I always drop in a test page similar to the following: Code:
<?php |
Quote:
I assumed you wrote the code by hand :) |
All times are GMT -5. The time now is 09:24 PM. |