Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

When using MAMP none of my PHP files are showing up...

So I set up MAMP on my Mac so that I can edit and view PHP files locally on my computer. Both Apache and MySQL Servers are lit up 'green' and I can see files listed when entering 'localhost' into my browser. It's just when I click on a specific PHP file I get a blank white screen with nothing. Any ideas?

11 Answers

Those two lines should be inside the <?php ?> tags, such as

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>

You can keep using http://localhost/includes/error_log to solve this though.

Open database.php and change the username and password both to "root".

That is odd. Double check PHP is working correctly.

Create a file called info.php and paste the following:

<?php 
phpinfo(); 
?>

Save. Then type in your browser: http://localhost/info.php to see if its loading correctly. If not, try a reboot and restart MAMP.

Joe,

I created info.php file and saved it then typed "http://localhost/info.php" into browser and I got a page that showed 'PHP Version 5.5.10' at the top and then sections like 'System' 'Build Date' 'Configuration Command', etc.

Sounds like everything is working properly.

Your php code could be causing an error. Add these two lines to the top of your code after the <?php

error_reporting(E_ALL);

ini_set('display_errors', '1');

When you click on your php files from the list, is it formatting your links as "http://localhost/file.php" or is it changing it to something like "file:///Applications/MAMP/htdocs/file.php"?

So I checked http://localhost/includes/error_log and it mentioned something about a database.php file so I added this to htdocs folder and now I'm getting this:

'Access denied for user 'davidgol_nym'@'localhost' (using password: YES)'

Got it. Sounds like your user/pass is incorrect. The default user/pass for MAMP MySQL is root/root unless you've changed it.

I added the two lines of code to the info.php file:

error_reporting(E_ALL);

ini_set('display_errors', '1');

and I just got that exact two lines of code at the top of the file when viewing in browser.

To answer your second question when clicking on my list of files they come up like this:

http://localhost/reservations.php http://localhost/test.php

etc.

I don't believe I've changed it. These files are a client of mine so I did not create these files. Could it have something to do with that?

Ah I see. If these are your clients files and you haven't imported a database with the same structure, you will most likely face a lot of errors coming up.

Sweet Joe! That was the issue.. Thank you man!

Awesome! Glad that helped!

changed username and password to root