PHP not running in Xampp

Alles, was PHP betrifft, kann hier besprochen werden.

PHP not running in Xampp

Postby screenprintr » 14. October 2019 17:12

Have a Windows 10 PC, with XAMPP. I place my files in c:/localhost/htdocs/PROJECT-FOLDER. I.E. whatever project I'm working on.

MySql works fine. created a Form login/register site, and it runs, however PHP doesn't seem to be working.

Created a Test program or two. Let's call them test.php, test2.php. Included the HTML, Head, Body tags, H1, and include <?php basic php code ?>. Yes, this is in: /localhost/htdocs/test.php and /localhost/htdocs/test1.php. Neither work from my FireFox browser. Did not try another browser.

Uploaded the files to my online hosting. Works fine there.

Any ideas of what I can do to fix this PHP issue? How do I troubleshoot this? MySQL and PHPMyAdmin works fine. Able to create database, tables, and columns.

Thank you in advance,

Paul
screenprintr
 
Posts: 4
Joined: 14. October 2019 16:52
XAMPP version: 7
Operating System: Windows 10

Re: PHP not running in Xampp

Postby Altrea » 14. October 2019 18:39

screenprintr wrote:Have a Windows 10 PC, with XAMPP. I place my files in c:/localhost/htdocs/PROJECT-FOLDER. I.E. whatever project I'm working on.

But you did not type in c:/localhost/htdocs/Project-Folder into your browser, did you?
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: 10977
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP not running in Xampp

Postby screenprintr » 14. October 2019 18:47

No, I only typed in /localhost/test.php and /localhost/test1.php

Not at home right now so I can't say the exact php version.
screenprintr
 
Posts: 4
Joined: 14. October 2019 16:52
XAMPP version: 7
Operating System: Windows 10

Re: PHP not running in Xampp

Postby Nobbie » 14. October 2019 21:57

screenprintr wrote:Have a Windows 10 PC, with XAMPP. I place my files in c:/localhost/htdocs/PROJECT-FOLDER. I.E. whatever project I'm working on.


... what is absolute total nonsense! Who told you to do so?

Put your files into c:/xampp/htdocs instead, for example c:/xampp/htdocs/test.php and finally execute it via http://localhost/test.php

Last not least urgently read the Xampp FAQ and the Apache Documentation about DocumentRoot. What you are doing here actually is a pain!
Nobbie
 
Posts: 12067
Joined: 09. March 2008 13:04

Re: PHP not running in Xampp

Postby screenprintr » 14. October 2019 23:10

Not sure what happen to my response. Nobbie is write. I saved my files in: c:/xampp/htdocs.

Also, since I'm not at home, I can't remember if I used Single or Double quotes. Double will take out the $ sign once you render the code.
screenprintr
 
Posts: 4
Joined: 14. October 2019 16:52
XAMPP version: 7
Operating System: Windows 10

Re: PHP not running in Xampp

Postby screenprintr » 15. October 2019 03:02

Sorry, Nobbie is Right.

So, once I got home I tried replacing single quotes with double quotes. It fixed some of the errors. The rest is due to Not Opening my PHP with the URL. If you open the PHP files with a Folder Dialog box you get the errors.

It was actually two issues that fixed the problems.

Thank you for your help. I found the Quote fix from Larry Ullman's book, Php and MySQL for Dynamic Web Sites, and the Opening a PHP file from the URL in this forum.
screenprintr
 
Posts: 4
Joined: 14. October 2019 16:52
XAMPP version: 7
Operating System: Windows 10

Re: PHP not running in Xampp

Postby stevehopely85 » 21. February 2020 08:30

This same thing happened to me when i was doing internship and it was my first exposure in web development :-) luckily my senior was tolerable.
stevehopely85
 
Posts: 2
Joined: 21. February 2020 08:15
XAMPP version: 10
Operating System: windows 8

Re: PHP not running in Xampp

Postby oto1 » 23. April 2021 17:25

I have the same problem. Apache is started. File test.php is inside test folder, which is inside the htdocs folder. Next I try to test if test.php (standard example) is working. Typing in the address bar http://localhost/test/test.php gives an output Not Found. The requested URL was not found on this server. Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.0.3 Server at localhost Port 80
Any suggestion to solve it and get test.php running?
oto1
 
Posts: 2
Joined: 23. April 2021 17:08
XAMPP version: 4.1.9
Operating System: windows 10

Re: PHP not running in Xampp

Postby Altrea » 23. April 2021 18:26

Nothing, PHP is working out of the box.
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: 10977
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP not running in Xampp

Postby oto1 » 26. April 2021 21:26

True, PHP is working out of the box. Thanks, Altrea.
Some more good news: the problem is solved.
Let's say the test.php file is <?php echo "Hello World"; ?>
The source of the problem is when you save the test.php file in Notepad.
You first write the File Name: test.php
But you must also go to the second line and Save as type: All type.
This solves the problem.
Remember also the path of files.
We created inside the htdocs folder the Test folder and placed inside it the test.php file (saved the correct way explained in the previous sentences).
To get the output of this php file from the localhost server, go to the address bar of your browser and type localhost/test/test.php
It gives the right output: Hello World
Conclusion: localhost works fine and you can use it to test your programs in an easy way, without having to use a remote server.
oto1
 
Posts: 2
Joined: 23. April 2021 17:08
XAMPP version: 4.1.9
Operating System: windows 10

Re: PHP not running in Xampp

Postby Altrea » 26. April 2021 22:25

oto1 wrote:The source of the problem is when you save the test.php file in Notepad.
You first write the File Name: test.php
But you must also go to the second line and Save as type: All type.
This solves the problem.

You should consider using a better editor or IDE for coding PHP like
  • Visual Studio Code
  • Sublime Text
  • Notepad++
  • PHPStorm
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: 10977
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: PHP not running in Xampp

Postby Eaglin » 19. May 2021 12:58

Dreamweaver is best tool to working with xammp and htdocs makes easier !!
Eaglin
 
Posts: 5
Joined: 20. April 2021 14:23
XAMPP version: 5.5.16
Operating System: windows 10

Re: PHP not running in Xampp

Postby Altrea » 19. May 2021 14:19

Eaglin wrote:Dreamweaver is best tool to working with xammp and htdocs makes easier !!

I don't agree here. Dreamweaver was a great editor 10-15 years ago. But nowadays it is not common to use. Early beginners liked the HTML WYSIWYG editor feature a lot, but only up to the point they realize how crappy the code is it produces and how less of control the programmer has.

But you are welcome to choose any editor you want to if it helps you to be a better coder.
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: 10977
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64


Return to PHP

Who is online

Users browsing this forum: No registered users and 7 guests