I am playing around with php through WAMP, trying to setup a small MySQL database and a webpage that can display and search through it. Everything worked for about 2 hours and I managed to make a php page that gets the rows from a given sql table and makes a html table and displays it.
All of a sudden the script stopped working. Even if I comment out or remove ALL code except the following all I get in Google Chrome is “Hello HTML world! and… ”
<html>
<body>
Hello HTML world! <br>
and... <br>
<?php
echo "Hello PHP World";
?>
</body>
</html>
The above code is in a .php file in the www folder of WAMP. As I mentioned above it was already working after the first install up until an hour ago. FWIW phpmyadmin is still working properly.
I already tried the following, in this order:
1) restart browser
2) restart computer
3) reinstall WAMP
4) clearing browser cache
5) editting “C:\Windows\System32\drivers\etc\hosts” to replace “::1 localhost”
with “127.0.0.1 localhost”
6) search this site and anything else that shows up in google search.
What could it be?
edit: Thank you for the quick replies!
I am opening the file in Chrome with the following URL “file:///C:/Program%20Files/wamp/www/new.php”
I have used it exactly the same about an hour ago and it worked perfectly back then.
If i use the “view source” option I see the content of the .php file, exactly the same as the code block in this post.
If you access it it via
file:///.....it will load the file without running it through the web server. So PHP will never get to run the script.You need to access it via
http://localhost/path/to/filename.phpin order for it to run through the server and have PHP do its thing.