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 CRUD Operations with PHP Project Setup Connecting to the Database

Qasim Hafeez
Qasim Hafeez
12,731 Points

Strange issue with console

When I open connection.php in the browser, the PDO Object shows up like expected. When I run the file in the console, however, i get this error

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory' in /Applications/MAMP/htdocs/CRUD_PHP_Project/inc/connection.php:3
Stack trace:
#0 /Applications/MAMP/htdocs/CRUD_PHP_Project/inc/connection.php(3): PDO->__construct('mysql:host=loca...', 'root', 'root')
#1 {main}
  thrown in /Applications/MAMP/htdocs/CRUD_PHP_Project/inc/connection.php on line 3

Does anyone have any idea what this is?