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
Brandon Brigham
3,716 PointsWhen 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
Joe Timmons
4,331 PointsThose 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".
Joe Timmons
4,331 PointsThat 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.
Brandon Brigham
3,716 PointsJoe,
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.
Joe Timmons
4,331 PointsSounds 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"?
Brandon Brigham
3,716 PointsSo 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)'
Joe Timmons
4,331 PointsGot it. Sounds like your user/pass is incorrect. The default user/pass for MAMP MySQL is root/root unless you've changed it.
Brandon Brigham
3,716 PointsI 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.
Brandon Brigham
3,716 PointsI 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?
Joe Timmons
4,331 PointsAh 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.
Brandon Brigham
3,716 PointsSweet Joe! That was the issue.. Thank you man!
Joe Timmons
4,331 PointsAwesome! Glad that helped!
Brandon Brigham
3,716 Pointschanged username and password to root