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 trialChris Komaroff
Courses Plus Student 14,198 PointsHello, I am not able to render database.php in my Chrome browser using my Mac
First attempt URL: file://localhost/Users/ckom9/Documents/Treehouse/Using_PHP_with_MySQL/htdocs/database.php The above will display my php source code, not web page.
Second attempt URL: localhost/Users/ckom9/Documents/Treehouse/Using_PHP_with_MySQL/htdocs/database.php This second attempt will fails with "web page not available".
I have commented out line with $db = new PDO(). So this is just a question about rendering a php web page on a browser using a Mac. Thank all for any assistance.
3 Answers
Chris Komaroff
Courses Plus Student 14,198 PointsYes, using MAMP as described in the earlier video works for me. Not really sure what problem is, but this should work out fine.
Chris Komaroff
Courses Plus Student 14,198 PointsP.S. here is complete code for database.php:
<?php
echo "Woo-hoo!";
?>
Robert Richey
Courses Plus Student 16,352 PointsHi Chris,
I get the first error, displaying php source code, when a server isn't running. If your server is running - I'm not sure. Has this worked for you before, or is this the first time trying?
Chris Komaroff
Courses Plus Student 14,198 PointsHi Robert, MySQL server is running, I checked again. I have been running php code in a html editor called Taco, but it may have a problem, so I want to run php script in Chrome. I went through intro to db using MySQL Workbench, but maybe I need to use MAMP as client in order to do the php with mysql course. But I think this may be very basic question about how to actually run php code (not containing any sql) locally in a browser.
Robert Richey
Courses Plus Student 16,352 PointsUnfortunately I have zero experience with Mac, but I can infer that MAMP may indeed solve the problem. A MySQL server, alone, would not be able to interpret and serve php code - that I'm aware of. It's Apache, the A in MAMP, that performs this job.
Hope this helps in some way.
Cheers
Robert Richey
Courses Plus Student 16,352 PointsRobert Richey
Courses Plus Student 16,352 PointsThat's great to hear, thanks for providing an update! Congratulations on getting that setup :)