PHP Displaying Source Code
Posted by: GregJones (---.72-176-173.mc.videotron.ca)
Date: May 07, 2020 06:21AM

Hello,

I've just installed on my computer. I was able to create a new directory and point it where it needs to go. When I go to open the index.php file my web browser displays only the soruce code.

Any ideas!? I looked through threads and couldn't find this.

Thanks in advance.

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: Otomatic (Moderator)
Date: May 07, 2020 09:01AM

Hi,

'http://localhost/mydir/index.php' NOT open file.

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.2 32 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30 - MariaDB 10.4.12
Wampserver 3.2.2 64 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30/8.0.20 - MariaDB 10.4.12
PhPMyadmin 5.0.2 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: GregJones (---.72-176-173.mc.videotron.ca)
Date: May 07, 2020 04:16PM

Hi,

Regardless of the method I use to open any php files, the source code appears in the browser.

Thanks

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: Otomatic (Moderator)
Date: May 07, 2020 04:56PM

Hi,

The homepage of Wampserver that you get with 'http://localhost/' in the address bar of your browser is the file wamp(64)/wwww/index.php

So, if your index.php file is in wamp(64)/wwww/mydir/index.php and is correctly written, to see the interpretation of the PHP code and not the source code, in the address bar of your browser, you should put: 'http://localhost/mydir/index.php'.

Clicking on the folder name (Your projects) in the Wampserver home page will do nothing.
You must declare your local sites as VirtualHost, as with all hosting providers.
See The need for Virtual Host and Wampserver 3 - Create or add a VirtualHost

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.2 32 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30 - MariaDB 10.4.12
Wampserver 3.2.2 64 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30/8.0.20 - MariaDB 10.4.12
PhPMyadmin 5.0.2 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »



Edited 1 time(s). Last edit at 05/07/2020 05:16PM by Otomatic.

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: RiggsFolly (Moderator)
Date: May 07, 2020 05:25PM

Hi,

Is it possible that you tried to install Apache manually, before finding WAMPServer? Is it also possible you didnt uninstall it yet?

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

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 MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: GregJones (---.72-176-173.mc.videotron.ca)
Date: May 08, 2020 04:41AM

Hey Riggs,

Yes it is entirely possible. I previously installed Bitnami. After the install, I was unable to view any /www folder so I found WAMP and installed that instead. I then deleted the Bitnami folder and nothing else... But even still, with Bitnami I was unable to see my pages, only source code.

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: Otomatic (Moderator)
Date: May 08, 2020 09:03AM

Hi,

Please READ (and answer) BEFORE YOU ASK A QUESTION

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.2 32 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30 - MariaDB 10.4.12
Wampserver 3.2.2 64 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30/8.0.20 - MariaDB 10.4.12
PhPMyadmin 5.0.2 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: GregJones (---.72-176-173.mc.videotron.ca)
Date: May 19, 2020 10:45PM

Hi, I am still having this issue.

My Wamp icon is green and I am able to access localhost. I am also able to access the php admin. But the default test .php pages that wamp come with display the source code and not the proper test page.

8 - Do you have access to localhost (Homepage WampServer)? Yes
8a - If so, is there an error message at the bottom of the page? No

9 - Do you have access to phpMyAdmin? Yes

10 - If you refer to an error message, please include the EXACT wording of the error in your post
11 - If you use an Antivirus and / or Firewall, please include the names of these kaspersky
12 - What is the full path to the installation of WampServer (eg D:\wamp\) c:/wamp64/
13 - If you have one or more Virtual Hosts defined, please show their definition(s)

I was able to create a new folder for my website root in the www folder, but again. index.php displays source code. Thank you in advance



Edited 1 time(s). Last edit at 05/19/2020 10:45PM by GregJones.

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: RiggsFolly (Moderator)
Date: May 20, 2020 03:01AM

I dont suppose you have IIS active by any chance?

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

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 MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: Otomatic (Moderator)
Date: May 20, 2020 08:43AM

Hi,

> index.php displays source code.

Wouldn't you use the short tags for opening PHP code?

That is <? instead of <?php

In this case - not recommended - you need to change the associated PHP directive :
Left-Click -> PHP -> PHP Settings -> short_open_tag

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.2 32 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30 - MariaDB 10.4.12
Wampserver 3.2.2 64 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30/8.0.20 - MariaDB 10.4.12
PhPMyadmin 5.0.2 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: GregJones (---.72-176-173.mc.videotron.ca)
Date: May 29, 2020 08:48PM

Hi, you are suggesting I change my open tag to shortcode?

Otomatic Wrote:
-------------------------------------------------------
> Hi,
>
> > index.php displays source code.
>
> Wouldn't you use the short tags for opening PHP
> code?
>
> That is <? instead of <?php
>
> In this case - not recommended - you need to
> change the associated PHP directive :
> Left-Click -> PHP -> PHP Settings ->
> short_open_tag

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: GregJones (---.72-176-173.mc.videotron.ca)
Date: May 29, 2020 08:49PM

Hi Riggs,

IIS is not actuve. should it be?

RiggsFolly Wrote:
-------------------------------------------------------
> I dont suppose you have IIS active by any chance?

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: Otomatic (Moderator)
Date: May 29, 2020 10:15PM

Hi,

> you are suggesting I change my open tag to shortcode?
No, I'm asking you to check your PHP scripts for "open tag shorts".

> IIS is not actuve. should it be?
NO.

Since you have access to the Wampserver homepage, i.e. localhost, this means that the PHP code is correctly interpreted; it also means that you have problems in your PHP scripts.

Write a simple PHP script like this
<?php
echo "Hello World";
?>
and save it in c:\wamp64\www\test\test.php

Then launch the Wampserver homepage and in the browser address bar, type :
'http://localhost/test/test.php'

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.2 32 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30 - MariaDB 10.4.12
Wampserver 3.2.2 64 bit - Apache 2.4.43 - PHP 7.4.7/7.3.19/..../5.6.40 - MySQL 5.7.30/8.0.20 - MariaDB 10.4.12
PhPMyadmin 5.0.2 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: PHP Displaying Source Code
Posted by: Stavros (---.netrun.cytanet.com.cy)
Date: June 01, 2020 08:13PM

I used to sometimes face the same problem back when I was installing Apache/PHP/MySQL manually. In most cases the problem was that PHP files were not parsed through the PHP interpreter and Apache served them directly as text files.

Therefore, make sure that you have installed the PHP 5.6.xx, which Wampserver uses, and any other newer PHP version for use by your websites. The PHP directories are being installed by default in the C:\wamp64\bin\php directory.

Check your apache configuration file ( click mouse's left button on the Wampserver icon --> Apache --> httpd.conf )
Let's suppose that you have installed Apache 2.4.41 and PHP version 7.4.6 in the directory C:\wamp64
The following directives should exist:
-------------------------------------------------------------
PHPIniDir "${APACHE_DIR}/bin"
LoadModule php7_module "${INSTALL_DIR}/bin/php/php7.4.6/php7apache2_4.dll"

<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
-------------------------------------------------------------

Also make sure that the APACHE_DIR and the INSTALL_DIR are defined. In the configuration file there should be directives similar to the following:
-------------------------------------------------------------
Define VERSION_APACHE 2.4.41
Define INSTALL_DIR C:/wamp64
Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE}
-------------------------------------------------------------

On a second thought, your antivirus/antimalware/antiWhatever may be interfering. Check them too.

Also, maybe you have a corrupt installation. Uninstall wampserver, do a fresh download of the installation application. and install again. Always remember to backup your databases.

Options: ReplyQuote


Sorry, only registered users may post in this forum.