[solved]problem with php

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

[solved]problem with php

Postby oddshoes » 14. May 2012 17:25

OS X lion 10.7.3, with 1.7.3. Also OS X Leopard 10.5.8 with 1.7.3.
I am having problems getting either of the above systems to process PHP, despite the fact that both say that the installation was successful and that the status in the start-up page says that everything is activated. I have placed a file index.HTML in the local host directory which reads fine either by copying the full address into the search bar of Safari or dragging and dropping the file into Safari. This file contains a link to a page test.php with a simple script – the usual Echo hello thing. The link works but the PHP does not run and the script is shown up as text. The fault condition is the same on both systems. Clearly there is something that I am not understanding, or maybe even lots of things. Could anyone give me any hints as to what to do or where to look?
Cheers
oddshoes
 
Posts: 2
Joined: 14. May 2012 17:21
XAMPP Version: 1.8.3-2
Operating System: OSX 10.5.8 &10.7.3

Re: problem with php

Postby Altrea » 14. May 2012 20:34

Hi oddshoes (there is ALWAYS time for an introducing welcome line, especially if you are asking for help. It's a matter of politeness),

oddshoes wrote:Clearly there is something that I am not understanding

serverside programming language files can't simply be opened in a program, they have to be processed, in your case by an php interpreter.
If you simply open the file in your browser, your browser simply doesn't know what to do with that file. Your browser analyzes the file, sees some HTML which he can render (it is really happy about that) and with the rest of the not understandable syntax he tries it's best to just output it as plain text.

Everything which results in an filebased path in your browsers address bar doesn't work. Webscript files has to be requested with a valid URL, like they are saved somewhere in the internet. For scripts saved on your own computer, the domainname localhost is mapped to your own computers loopback IP address 127.0.0.1. This domainname can be used in URLs.

Your Apache Webserver is listening on requests from a special port (by default port 80) and tries to find the file inside his allowed folder structure.
By default /Applications/XAMPP/htdocs/ is the root folder for your Apache. This root folder can be requested very simple by requesting your local domainname http://localhost/
Every folder and file inside this root folder can be accessed by adding the name of it in the URL. For your example:
If you want to request your file /Applications/XAMPP/htdocs/sitename/index.php The URL will be http://localhost/sitename/index.php

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: 6545
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: problem with php

Postby oddshoes » 16. May 2012 19:03

Hello, thanks for your reply. I am very sorry to have caused offence by my lack of initial greeting, I come from a part of the world where we do not stand very much on ceremony (Yorkshire). So sometimes my communications are perhaps a little abrupt. We do however make a big thing of thanking people for their freely given advice.
Your explanation has enabled me to solve the problem and I now understand in a little more depth the workings of the web server software. So: the browser can identify the address is being a simple file address and go straight there this missing out the web server. Using the HTTP://forces the browser to go via the web server where the.php file name is identified and processed. Such a lot to learn for my somewhat ageing brain!
Once again many thanks further help.
oddshoes
 
Posts: 2
Joined: 14. May 2012 17:21
XAMPP Version: 1.8.3-2
Operating System: OSX 10.5.8 &10.7.3

Re: problem with php

Postby Altrea » 16. May 2012 22:49

oddshoes wrote:I come from a part of the world where we do not stand very much on ceremony (Yorkshire).

:lol:

oddshoes wrote:Your explanation has enabled me to solve the problem and I now understand in a little more depth the workings of the web server software.
Such a lot to learn for my somewhat ageing brain!
Once again many thanks further help.

You're welcome. I'm glad my explaination was helpful for you.
I wish you all the best and much fun with XAMPP and all that stuff.

P.S.: marked the topic as solved
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: 6545
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 1 guest