23

I have a problem running PHP in XAMPP 1.7.7 for windows. I've installed XAMPP in a local server with IIS (changed the port to 81 in httpd.conf as well as other configuration) so far it works and I could connect to the xampp/index.php but coulnd't run any .php files in my htdocs (shows blank except for the html part). It works in my local (also have an IIS installed) but couldn't make it work in a server.

Any help would be much appreciated.

3
  • 1
    The A in XAMPP stands for Apache. If you don't have a extremely good reason to use IIS, don't use it! Commented Feb 23, 2012 at 3:02
  • you asked the wrong question. You PHP is working but you want to access it across a different computer and that's when it does not work? Commented Feb 23, 2012 at 21:09
  • The crocodile hunter>Sorry for the misunderstanding I meant my XAMPP is working but could not run any PHP files. I've tried it in a different computer and its working so I guess it has something to do with changing of ports. Commented Mar 1, 2012 at 0:54

6 Answers 6

67

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.

Sign up to request clarification or add additional context in comments.

Comments

8

Create a folder in htdocs like "test".

Then in test put index.php with a simple Echo 'Hello';

Then on your browser (make sure apache + mysql are running in control panel).

Visit this in your browser:

http://localhost/test/index.php

If your trying to connect via your IP then your router must be stopping it so you have to sort the settings out. I don't know your router make/model you better off asking their support forums.

Personally i stuck with port 80. 80 doesn't work in windows 7 because a service is using it. How ever, its a simple fix, just go to "Services" and disable "World Wide Web Publishing Service". Then port 80 is free to use on localhost. (Don't worry your internet will work just fine disabling that service). It'll auto re-enable on next boot so you have to remember that.

3 Comments

Thanks for the reply. Yes I've tried your sample but it only returns blank. I changed the port to 81 because my IIS server is using the default port 80. I could connect to the xampp index.php but still couldn't run any .php file.
Have you got the latest version of Xampp?
Yes XAMPP 1.7.7 just downloaded it a while ago in their website or is there a more stable version? I've tried installing it in my other computer (with IIS) and it worked fine and I'm currently installing it in our server.
6

Use this:

http://localhost/data.php

instead of this:

C:\xamp\htdocs\data.php

1 Comment

You should provide and explanation and format code correctly.
4

Make sure you are not running it as a file from your drive, (my example):

*file:///C:/xampp/htdocs/(path)*

but rather as a webpage, which means the address must start with "localhost"

*http://localhost/(path)*

If you are using a different port (not the standard 80, but for example 8080), then:

*http://localhost:8080/(path)*

Comments

4

I had the same problem. For me worked to change <? ... ?> to <?PHP ... ?> in the script. Maybe new wersion of PHP doesn't support the first definition of PHP script.

Comments

-1

Simply..

  1. Save the file/code first(EVERYTIME),"command + s" everytime.

  2. Refresh the browser.

good to go

1 Comment

Control (ctrl) + S maybe :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.