PHP not executing in html code
Posted by: teremoto (98.51.42.---)
Date: April 24, 2022 05:26AM

I have been trying to resolve this for over a week. I found lots of people with similar problem and the fixes are basically adding : AddType application/x-httpd-php .html
AddType application/x-httpd-php .php
to the http.conf file.
This doesnt resolve. I can run a test file with a php extension and it works. when i embed just an echo statement within html code the php code is not executed. The files I am using have a php extension. I am not using short tags (using <?php <?>winking smiley.
i have checked that wamp has loaded the php module.

I am using wamp server64 , apache 2.4.51. php7.4.26 on a windows 11 laptop

Can anyone help with this?
thanks

Options: ReplyQuote
Re: PHP not executing in html code
Posted by: Otomatic (Moderator)
Date: April 24, 2022 10:47AM

Hi,

There is nothing to add or change in the httpd.conf file.

HTML embedded in PHP works without any problem, of course, as long as the code is correctly written. You have a flagrant proof with the file wamp64/www/index.php that is the Wampserver homepage 'http://localhost/'

What is the code that doesn't work ? and what is the full name of the file with this code ?

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: PHP not executing in html code
Posted by: teremoto (98.51.42.---)
Date: April 24, 2022 05:57PM

The file name is index.php. i am executing the program thru the browser with localhost/Dmac/index.php.
The code is
<html>
<head> <h1> First Program </h1>
</head>
<body>
<?php>
echo "First Program max";
<?>
</body>
</html>

I am stumped as to what to do next. Should I reinstall everything?

Options: ReplyQuote
Re: PHP not executing in html code
Posted by: Otomatic (Moderator)
Date: April 24, 2022 06:09PM

Hi,

The code must be :
<html>
<head> <h1> First Program </h1>
</head>
<body>
<?php
echo "First Program max";
?>
</body>
</html>
The opening tag of php code is: "<?php" and not "<?php>" as well as the closing tag of PHP code is "?>" and not "<?>".

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: PHP not executing in html code
Posted by: teremoto (98.51.42.---)
Date: April 24, 2022 07:01PM

oh my.....thank you so very much. All this time spent trying to resolve what I assumed was a configuration issue and the problem was my code syntax being incorrect. I cant thank you enough.

Options: ReplyQuote


Sorry, only registered users may post in this forum.