embedded PHP in HTML not running.
I hope someone can help me with this as I cannot find an answer any where else.
I have installed Apache 2, and php4 on my WinXP home machine.
The problem I am getting is that when I embed php script in html pages the script is not getting run.
So the following page will only display goodbye in the browser.
PHP Code:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo "<p>Hello World</p>"; ?>
goodbye
</body>
</html>
The strange thing is if I navigate to a file with the php extension with php code in it works fine. This file was called http://localhost/hello.php
PHP Code:
<?php echo "hello world" ?>
Hello World is displayed in the browser.To setup PHP I followed these instructions
When compared to the official PHP installation instructions I have done everything right. :( I think.
Re: embedded PHP in HTML not running.
Quote:
Originally posted by davidrobin
The strange thing is if I navigate to a file with the php extension with php code in it works fine.
ok.. after reading that sentence, PLEASE, tell me you aren't trying to execute PHP in a file with the extension HTML. Unless you told Apache to recognize .html/.htm as your PHP extension, it isn't going to execute it. You absolutely HAVE to name it [name].php for Apache to recognize it and tell the PHP engine to parse it.
Re: Re: embedded PHP in HTML not running.
Quote:
Originally posted by kows
ok.. after reading that sentence, PLEASE, tell me you aren't trying to execute PHP in a file with the extension HTML. Unless you told Apache to recognize .html/.htm as your PHP extension, it isn't going to execute it. You absolutely HAVE to name it [name].php for Apache to recognize it and tell the PHP engine to parse it.
Nice catch, kows. I thought he meant the problematic file was the .php file.
You CAN setup your Apache to parse .html files...but anything you make wont work on any other server unless it's setup the same way, which isn't common.
As kows said, for PHP code to work, it has to be a .php extension. You can't just plot PHP code in a .html file.