I started a PHP/MySQL class today and we're using Murach's PHP and MySQL book. We're instructed to use XAMPP for Mac for our server stack, I have it installed and running, but no matter which browser I use the PHP file that's supposed to be rendered is downloaded instead. I have no idea what this is. Any help?


*Update


Wow, 2 down votes for asking a simple question? Some community. Turns out I needed to do some reorganizing in my XAMPP root directory.

So to those of you who thought that it was necessary to down vote me and ridicule me for asking this question, piss off. To @Suhoij, @Tim Parenti and @Senad Meškin, thank you for actually putting effort into your post and giving me useful pointers and answers with actual substance. To everyone else who was inquiring on what I was doing to possibly help me further, thank you for being decent community members.

link|improve this question
1  
Sounds like your local server is not configured to properly interpret PHP files. – Jason McCreary Oct 24 '11 at 20:07
2  
Browsers don't render PHP. They render HTML. Your server is misconfigured and has not been told to pass .php files to the PHP interpreter. – Marc B Oct 24 '11 at 20:07
2  
You have to read your book more carefully. Browsers do not rended PHP files, go figure – Col. Shrapnel Oct 24 '11 at 20:07
3  
You're calling the files via localhost rather than via their filenames? e.g. http://localhost/test.php – Michael Oct 24 '11 at 20:07
1  
Is your php file located in the www-folder of the installation? – Marcus Oct 24 '11 at 20:08
show 2 more comments
feedback

migrated from stackoverflow.com Oct 25 '11 at 2:30

This question came from our site for professional and enthusiast programmers.

3 Answers

Make sure you're pointing your browser to http://localhost/foo.php and not the actual location of the file foo.php in your htdocs directory. This will cause XAMPP to run the PHP script and pass the HTML output on to your browser which displays it, whereas calling up the file directly will simply "download" the PHP file as you described.

link|improve this answer
feedback

It's not up to browser to render PHP file, Browser only sends request to server and receives in your case HTML.

Probably problem is that your Apache server is not configured to use PHP as engine for php files.

You should check your Apache and PHP settings, and make sure that your server is started.

Try to access your web files like http://localhost/webdirectory/phpfile.php

link|improve this answer
feedback

Looks like Apache is not configured properly. You need to add php handler. It must be done in httpd.conf. This is how my httpd.conf looks like: AddType application/x-httpd-php .php3 .php AddType application/x-httpd-php-source .phps. Read here http://dan.drydog.com/apache2php.html and here http://www.webmasterworld.com/apache/3418477.htm.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown