I have: Apache 2.2.1 Php 5.3.6 MySQL 5.5.10 All up and running fine. I can server HTML and PHP pages just as advertisedized. What I can not do is embed PHP in the HTML page. I have tried all the different types of escape code: <? ... ?> <?php ... ?> <script language="php" > ... <?script> <% ... %> None of them have the slightest effect. I think I must have Apache configured wrong - but where?
Hi James, If you want PHP to be parsed inside a HTML file then you need to tell Apache to treat the .html / .htm extension as a PHP file. Otherwise it is just treated as plain HTML and will output your code as plain text. You can do this by editing the AddType in your httpd.conf file. In that file there should be a line like this: AddType application/x-httpd-php .php Code (markup): Simply change that to: AddType application/x-httpd-php .php .html .htm Code (markup): Restart Apache and then your HTML files will parse your PHP code.
I'm having a similar issue. While I can view includes with .shtml extensions, if I try to use PHP includes, they don't get parsed by the browser. I know the syntax is right because the includes do come up correctly when I upload the website to the hosting server. This is what I currently have in the httpd.conf file: AddType text/html .shtml .php AddOutputFilter INCLUDES .shtml .php I am running Apache 2.2 and Windows XP. Thank you for your help!
First of all make sure you have PHP installed. Just having Apache installed won't give you PHP on your local machine. SHTML Includes and PHP Includes are completely different. Your code in the .shtml files is probably fine, they work when you upload them to the hosting company because the hosting company has Apache httpd.conf file configured correctly. The first line, your telling Apache to parse .shtml and .php extensions as text/html and in the second line your telling Apache to parse .shtml and .php for SHTML Includes. PHP includes will not be affected by this setting because the files are initially being parsed as text/html. You need to tell Apache to parse .shtml extensions as though they were PHP. I am assuming based on your post that all of your files are named index.shtml file1.shtml, file2.shtml and that you are not using the .php extension at all. Therefore the following should work for your situation: AddType application/x-httpd-php .shtml AddOutputFilter INCLUDES .shtml Code (markup): If you are using files which end with the .php extension, e.g. myfile1.php, includea.php, includeb.php then change the first line to: AddType application/x-httpd-php .shtml .php Code (markup): Note that I have not tested this as I have no use for SHTML and haven`t used it for years, but I am pretty sure it's correct.
first of all I assume you are using a *Nix based system run httpd -M Code (markup): and check if php5_module is loaded If not install it.