php code

Problems with the Windows version of XAMPP, questions, comments, and anything related.

php code

Postby nick1986 » 02. October 2017 08:01

Hello.

I've installed xampp 7.1.9 on my Windows 10 64 bit, and i can't run my php code properly.
Apache and MYSQL are running properly in my control panel, but i can't execute php code properly.
Also, in the index page in the htdocs folder, i get the message that something went wrong with the xampp instalation.
What can i do about it ?
nick1986
 
Posts: 3
Joined: 02. October 2017 07:57
XAMPP version: 7.1.9
Operating System: Windows 10

Re: php code

Postby Altrea » 02. October 2017 15:09

Hi,

Please describe as detailed as possible how you are trying to "run" your php files.

Best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8969
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: php code

Postby nick1986 » 02. October 2017 15:22

OK, so :

Trying to run a simple code :

<?php

echo "Hello.";

?>

After that, i try to run it on Firefox browser and the result is that i see an empty page.
After that, i go to the index.php page in the htdocs folder at xampp, and it delivers that message :

<?php
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
$uri = 'https://';
} else {
$uri = 'http://';
}
$uri .= $_SERVER['HTTP_HOST'];
header('Location: '.$uri.'/dashboard/');
exit;
?>
Something is wrong with the XAMPP installation :-(

Gotta say that once i had windows 7 and had no problems with php code running.
Maybe changing to 7 or 8 will do...
nick1986
 
Posts: 3
Joined: 02. October 2017 07:57
XAMPP version: 7.1.9
Operating System: Windows 10

Re: php code

Postby Altrea » 02. October 2017 15:26

nick1986 wrote:After that, i try to run it on Firefox browser and the result is that i see an empty page.

HOW do you run that file in Firefox? What do you do? What does your Browsers address bar show?

nick1986 wrote:Gotta say that once i had windows 7 and had no problems with php code running.
Maybe changing to 7 or 8 will do...

The problem is not your operating system. The problem is the way you run the php file.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8969
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: php code

Postby nick1986 » 02. October 2017 18:46

How do i run the file ?
Type the code in Notepad++ and then press "Run->Launch with Firefox".

What does the address bar show ?
file:///C:/xampp/htdocs/new%201.php
nick1986
 
Posts: 3
Joined: 02. October 2017 07:57
XAMPP version: 7.1.9
Operating System: Windows 10

Re: php code

Postby Altrea » 02. October 2017 19:39

That is the problem. Your browser does not speak php. It has no idea what to do with all of the code between <?php and ?>.
It can only do it's best to visualize all the HTML in that file and skip all that HTML invalid php code.

PHP files need to be processed by an php interpreter first. The PHP interpreter take all the PHP magic, process it and sends back plain HTML to the requesting browser.
Your browser cannot know that there is a PHP interpreter installed on your very own computer, it doesn't have to know that.

You need to request the file correctly in your browser. For that you can use the local URL http://localhost/
For example: http://localhost/index.php will request the php file \xampp\htdocs\index.php
The URL http://localhost/projectxy/file.php will request the file \xampp\htdocs\projectxy\file.php

I hope this makes sense to you. This cannot have been working ever the way you are trying.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8969
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: Anancuras\ and 37 guests