Newbie: can't run php script embedded in html
Posted by: jonathanhuie1 (---.hsd1.ca.comcast.net)
Date: March 15, 2010 08:51AM

Hello,

I just downloaded wampserver2 and I saved this code:

<html>
<head>
<title>PHP Test Title</title>
</head>
<body>
<?php
echo "<p>Something</p>" ;
?>
</body>
</html>

under C:\wamp\www\test.html

When I open the test file with the browser, all I can see is the page title but the php statement does not execute.

Any help would be greatly appreciated.
Thanks!!!

Options: ReplyQuote
Re: Newbie: can't run php script embedded in html
Posted by: ryepie (---.sd.sd.cox.net)
Date: March 15, 2010 03:23PM

I believe you have to save the file as test.php, not test.html in order for the server to know it has to execute the php script.

Options: ReplyQuote
Re: Newbie: can't run php script embedded in html
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: March 15, 2010 06:02PM

By default WAMP configures Apache to only parse PHP code within .php files. If you want .html files to be parsed by PHP you'll need to open the httpd.conf (left click WAMP tray icon and choose Apache > httpd.conf

Find the following line
AddType application/x-httpd-php .php

Now underneath that line add
AddType application/x-httpd-php .html

Save the httpd.conf and restart the Apache service.

Options: ReplyQuote
Re: Newbie: can't run php script embedded in html
Posted by: jonathanhuie1 (---.hsd1.ca.comcast.net)
Date: March 16, 2010 02:34AM

Hi,

Thanks very much for your responses.

c2dan --- I tried exactly as you indicated, added the new line in the hpptd.conf file. It is STILL not executing the PHP line. All I get is a new blank html title page.

ryepie --- I also tried renaming the test.hmtl to test.php. And when I click on the test.php file, I would get a popup dialog box asking me whether I would want to "Open" or "Save" the test.php. When I select the option "Open" it then tries to open but unsuccessful and comes back with the same dialog box.

Somehow, I'm not able to connect to PHP. Any idea why?

Do you think you can run the scipt above on your system to see whether it works for you? If it works on yours, then something is definitely wrong with my installation/settings.

Thanks!

Options: ReplyQuote


Sorry, only registered users may post in this forum.