Running external php file from HTML page

Hi everyone
This is my “hello.php” file:
[php]

<?php $myConnection = NEW MYSQLI('localhost','root','a','b'); IF(!$myConnection) DIE('ccc' .MYSQLI_CONNECT_ERROR()); echo 'Hello world'; ?>

[/php]
When I load it thorough my browser typing at the address bar:
http://localhost/hello.php I get an “Hello world” declaration on my display.
Then I create an hello.HTML file with the following code:

<!DOCTYPE>
<html>
<head>	
</head>
<body>
	<a href="hello.php">php</a>				
</body>
</html>

when I load “hello.html” and click “php” anchor, what I get at my display is the php file’s source code.
I dont get the desired “Hello world”.
Could anyone tell me why and what should I change to make the browser show “Hello” and not the source code?
Thanks

Did you use the address http://localhost/hello.html to do so?

Keep off the mixed case. Stick to always using lowercase with an under_score_to_seperate_words and NEVER EVER output system errors to the user. That info is only good for hackers. Use proper error logging and reporting. Since you are just starting out, now is a good time to start using PDO. https://phpdelusions.net/pdo

No phdr, I did not ! Thanks a lot !

Sponsor our Newsletter | Privacy Policy | Terms of Service