PHP Not Working in Xampp

PHP not working in XAMPP

If I got your question correctly, I think I had the same problem accessing a php file in XAMPP. I have been online for several hours searching forums and Google for the answer, not until I found the simple solution.

I was accessing the PHP file as a file on c drive (eg. C:\xamp\htdocs\data.php or file:///c:/xamp/htdocs/data.php) instead of as a webpage (ie //localhost/data.php).

I hope this will be helpful to you as well.

php code not working working on xampp

Answer based on comments.

PHP file must be interpreted by web server (in your case - apache with php extension, which is part of XAMPP), which executes PHP code and sends script output/result via http protocol to web browser.

To execute PHP script and show it's result you have to use HTTP, like this: http://localhost/doctrinetest/welcome.php.

c:\xampp\htdocs directory is "served" at http://localhost/ URL.

Opening that file via filesystem (not using apache server) will output blank page, because browser is not supposed to execute PHP. However, that blank page will contain your static HTML part of code.

It looks like, you dont understand how PHP works. You need to read some books about web fundamentals.

Eventually you can visit http://thenewboston.org or http://phpacademy.org - they have very good educational videos.

PHP not executing with XAMPP (Windows)

Your PHP code are not executing because the server interpret the file as text file, hence why the codes are not executing. This is due to your file name, which have .txt extension.

not sure how to get rid of the .txt suffix

Use any code editor like Notepad++ to save the file as PHP file, hence getting rid of the .txt extension.

Or for normal Windows Notepad, just select save as "all file", and the file name make sure only "index.php".

Not Found The requested URL was not found on this server. xampp error

You may have another apache instance running. Try to visit http://localhost and see whether the xampp dashboard opens up. If not then we can safely assume that you are still running your other apache instance (c://AppServ/Apache24).

a) Open the task manager and search for a apache24 process. If there's one then end it. And then retry to start the xampp apache server.

Or if you don't need that apache server, you can uninstall it from the system.

If the xampp dashboard comes up by visiting the localhost url, then you are running the xampp server. (please make sure that you have only one xampp server installed)
if so,

a) Are you trying to visit "http://localhost/chou", and then this error comes up?

  • Then you may have a redirect script or a .htaccess file with some redirect rule. in the site root.

b) Does this file ("chou/connecter.php" ) exists in the htdocs directory.

c) If the xampp apache is listening on port 8080, Then Did you try to open http://localhost:8080/chou/connecter.php

If nothing above works, Please provide more details.

PHP script not working in HTML file

XAMPP already includes PHP, but unless you end the script name with .php it is unlikely to be processed by the PHP engine.



Related Topics



Leave a reply



Submit