php doesn't seems to work
Posted by: Kayurin (---.26-151.libero.it)
Date: February 25, 2015 09:39PM

I have wampserver installed and running.

Windows 8.1
WampServer 2.5
Apache Version 2.4.9
PHP Version 5.5.12
MySQL Version 5.6.17

All of the above on 64 bit version.

The Wampserver icon is green, I have accesso to Localhost and phpMyAdmin pages.

Now I tried a simple php code I have found on a tutorial (I'm learning the trade.) specifically this one:

<html>
<head>
<title>My first PHP page</title>
</head>
<body>

<?php

echo "<h1>Hello World!</h1>";

?>

</body>
</html>

The result was supposed to be something like this:

[html.net]

but running it from my www folder gives me just a white page with

Hello World!"; ?>

written on top right... Exactly like that.

Now my newbie guess is that php is somewhat not enabled, but I have searched the web and php should came already enabled with wampserver...

What I'm doing wrong?

Thanks in advance...

Options: ReplyQuote
Re: php doesn't seems to work
Posted by: RiggsFolly (---.as43234.net)
Date: February 25, 2015 11:04PM

Make sure the filename of your page end in a .php

The php interpreter is only called if the filename end in .php


eg
test1.php

and not
test1.html

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: php doesn't seems to work
Posted by: Kayurin (---.26-151.libero.it)
Date: February 25, 2015 11:28PM

Yes, is a .php

I created it with notepad, then saved it with "save as"->all files->added .php in the end.

If I go rightclick->properties it says it's a .php file.

Options: ReplyQuote
Re: php doesn't seems to work
Posted by: RiggsFolly (---.as43234.net)
Date: February 26, 2015 12:04AM

Are you sure! notepad tends to add .txt on the end of a saved filename and if you dont have explorer set to show filename extensions its not obvious


I suggest you download and install notepad++, its free and a good code editor.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: php doesn't seems to work
Posted by: Kayurin (---.26-151.libero.it)
Date: February 26, 2015 12:19AM

I double checked and decided to download Notepad++, copy this code:

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html>

On it, save it as test.php (Selected the .php option from the scrolldown menu.) and testing it gave similar results.

Hello World!"; ?>

on a blank page.

I'm runnning Chrome, but even if I go "open with" and select IE, the only difference is about the browser asking if I want to dowload or open the file...

Options: ReplyQuote
Re: php doesn't seems to work
Posted by: RiggsFolly (---.as43234.net)
Date: February 26, 2015 02:11AM

Are you doubleclicking on the filename using explorer???

If so DONT!

In order to get a PHP script interpreted you have to run it properly i.e. enter
http://localhost/test.php
into the browsers address bar

This will cause apache to try and load the script, when apache sees the .php extension it passes the script to the PHP interpreter for processing and runs the script.

If you just doubleclick on the filename no PHP interpreter gets called, that method only works with vanilla HTML and JAVASCRIPT.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: php doesn't seems to work
Posted by: Kayurin (---.26-151.libero.it)
Date: February 26, 2015 02:28AM

Oh...

That was the problem, sorry but as I said I am learning the ropes for php and html... (If you can address me to some good tutorials\lessons I'd appreciate it a lot...)

Anyway now it works, thanks for all the help and the time...

Options: ReplyQuote


Sorry, only registered users may post in this forum.