Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP & Databases with PDO PDO Queries & Results Query by ID

Igor Prymak
Igor Prymak
13,590 Points

"could not find driver" Error

Both in a Workspace and in PHPStorm IDE (PHP interpreter configured) I get the following error when trying to run index.php from this lesson: "could not find driver". Looks like I am not the only one with this problem on a forum, but it haven't been addressed yet. The code is correct, I didn't change it. Seems like the error is occurring while index.php is requiring database.php.

1 Answer

have you run it through the browser to see if it works there? i mean through wamp/mamp/vagrant etc whatever you use... maybe your IDE doesnt have the mysql driver..

Igor Prymak
Igor Prymak
13,590 Points

Thanks for your response. On xamp the site partially works, but I get the following error: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected Haven't changed anything in the code – just copied it over to htdocs. The string for connecting to DB is as follows: $db = new PDO('mysql:./database.db');