PHP does not work after installation

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

PHP does not work after installation

Postby refloghctarcs » 11. January 2011 21:37

I have just installed the XAMPP package using all the defaults. After the installation I started all the services. There are two file in the htdocs directory; 1) index.html and index.php. When I run the .html file it produces "It Works!' When I run the .php file I get "Something is wrong with the XAMPP installation :-( ". I tried re-installing XAMPP with the same result.

Any suggestions?

Thanks,

Bob
refloghctarcs
 
Posts: 4
Joined: 11. January 2011 21:29

Re: PHP does not work after installation

Postby Sharley » 12. January 2011 01:01

refloghctarcs wrote:When I run the .html file it produces "It Works!' When I run the .php file I get "Something is wrong with the XAMPP installation
How do you 'run' these files?
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: PHP does not work after installation

Postby refloghctarcs » 12. January 2011 01:42

From my Browser in the address line c:\xampp\htdocs\index.html , c:\xampp\htdocs\index.php. The file runs because that is the message hardcoded in the php file. I have also tried the lite version at the same request. If it helps I am running XP on a Lenovo lap top.
refloghctarcs
 
Posts: 4
Joined: 11. January 2011 21:29

Re: PHP does not work after installation

Postby Sharley » 12. January 2011 01:56

This method is not possible for .php files as they need to be parsed by a running web server.

So type http://localhost/ and you should see the XAMPP Welcome Demo Page.
Same if you type any of these:
http://localhost/index.php
http://locahost/xampp/
http://localhost/xampp/index.php

All of your other .php extension files require this type of URI.

.html extension files will run without going through the web server as the code is translated by your browser and is why you could see the "It Works!" when you clicked on or type a .html file path in your browser.

.php extension files will not run without going through a web server as the code is translated, in XAMPP's case, by the Apache web server before it is sent to your browser and is why you received the other hard coded error message in your browser.

So your browser could read the error message "Something is wrong with the XAMPP installation :-(" but could not translate the included <?php code ?>.

Good luck and best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: PHP does not work after installation

Postby refloghctarcs » 12. January 2011 02:40

I really appreciate your help.

I have reinstalled the xampp files.

I do get the splash page. Now, I have a sub directory c:\xampp\htdocs\dcmc which contains my sites files. What would be the URI to open the files in the site directory, dcmc. I tired http://localhost/xampp/htdocs/dcmc/Page8.php and http://localhost/xampp/htdocs/dcmc/Index.html and get an 404 Object not found error.

I also tried to open the files in the htdocs directory with http://localhost/xampp/htdocs/Index.html and I get the 404 error.

Thanks,

Bob
refloghctarcs
 
Posts: 4
Joined: 11. January 2011 21:29

Re: PHP does not work after installation

Postby refloghctarcs » 12. January 2011 02:44

Never mind i figured out what I was doing wrong, thanks again for your help!


Bob
refloghctarcs
 
Posts: 4
Joined: 11. January 2011 21:29

Re: PHP does not work after installation

Postby Sharley » 12. January 2011 02:48

Just to explain for others reading this topic, you don't need to add the htdocs folder to your URI.

http://localhost/dcmc/
Will server your index file.

http://localhost/dcmc/Page8.php
Will server your Page8.php file.

The server knows where your web files are located because the DocumentRoot is C:\xampp\htdocs folder and so no need to add these locations.

Only XAMPP files are and should be located in the C:\xampp\htdocs\xampp folder.

Hope this helps.

Good luck and best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: PHP does not work after installation

Postby eleni » 29. January 2011 22:39

hello!
I have the same problem. When i type http://localhost/xampp/index.html or http://localhost/xampp/index.html i get 404 Object not found error.
I can only access http://localhost/xampp.
At logs file i see the message [Sat Jan 29 23:28:16 2011] [error] [client ::1] File does not exist: C:/Program Files/xampp/htdocs/xampp/htdocs.
What's wrong ?Can you please help me?
Thanks
Eleni
eleni
 
Posts: 3
Joined: 29. January 2011 22:15

Re: PHP does not work after installation

Postby Sharley » 29. January 2011 23:04

eleni wrote:When i type http://localhost/xampp/index.html or http://localhost/xampp/index.html i get 404 Object not found error.
Those URIs are both the same, did you mean to type 2 different URIs?

Look in the C:\xampp\htdocs\xampp folder and you will see there is no index.html file only an index.php file.

http://localhost/xampp/index.html will give error 404 file not find which is correct.
http://localhost/index.html will load the htdocs\index.html file and give It Works! page.
Http://localhost/ will load the htdocs\index.php file and redirected to... http://localhost/xampp/index.php
http://localhost/xampp/ will load the index.php file also.
http://localhost/xampp/index.php will load the index.php file also.

With Apache and MySQL running you can verify the above links by simply clicking on them.

Best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: PHP does not work after installation

Postby eleni » 29. January 2011 23:25

Thank you for your fast reply.
I want to create my own html,php fles.
I created a simple .php file (hello world). I've put it inside a new file named elen (which is inside the htdocs file).
When i type http://127.0.0.1/xampp/elen/index.php or http://127.0.0.1/xampp/htdocs/elen/index.php
i got the same message Object not found! why is that?
eleni
 
Posts: 3
Joined: 29. January 2011 22:15

Re: PHP does not work after installation

Postby eleni » 29. January 2011 23:35

Now it worked!
I should use http://127.0.0.1/elen/index.php
Now i got it.
Thank you again for your fast reply!

Best Wishes
Eleni
eleni
 
Posts: 3
Joined: 29. January 2011 22:15

Re: PHP does not work after installation

Postby JonB » 29. January 2011 23:38

Thank you for your fast reply.
I want to create my own html,php fles.
I created a simple .php file (hello world). I've put it inside a new file named elen (which is inside the htdocs file).
When i type http://127.0.0.1/xampp/elen/index.php or http://127.0.0.1/xampp/htdocs/elen/index.php
i got the same message Object not found! why is that?


Because the documents are NOT in the 'xampp' folder that is below htdocs (look you will see there is one, and that is where the 'XAMPP' Wlcome page and its children live)

You say you put a FILE names 'elen' - what kind fo file???? Do you rally mean FOLDER?

the CORRECT url for a FILE named index.php in the FOLDER named 'elen' would be:

EITHER http://localhost/elen/index.php OR http://127.0.0.1/elen/index.php.

Nomenclature is fairly important, I can't see how this subject can be tackled without learning it.

Good Luck
:)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: PHP does not work after installation

Postby Sharley » 29. January 2011 23:41

No need to type a folder name after the localhost bit as your files are stored in the localhost DocumentRoot folder htdocs.

So http://localhost/elen.php will find it.

If you named your hello world file index.php then
http://localhost/index.php
will find it but to do that you would need to remove or rename both the index.html and the index.php already in the htdocs folder and replace it with your own.

Good luck.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: PHP does not work after installation

Postby LuvBug » 02. February 2011 04:05

Hi Everyone,

New to the forum. I installed xampp without any issues. Apache is running and the php status is green. When I run http://localhost/test.php from firefox I get the same error message (Object not found!). However, when I run http://localhost/index.php this loads fine with no issue. This is all that I'm trying to run. Thank you...

<?
phpinfo();
?>
LuvBug
 
Posts: 3
Joined: 02. February 2011 03:51

Re: PHP does not work after installation

Postby Sharley » 02. February 2011 04:25

Try
Code: Select all
<?php
phpinfo();
?>
Short_open_tags are disabled because they are deprecated and will not be available in newer PHP versions - the explanation is in the php.ini file.

Also you could try
http://localhost/xampp/phpinfo.php
as it is already linked in the menu options in the XAMPP Welcome Demo Page
http://localhost/xampp/index.php

Good luck.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 38 guests