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 Integrating PHP with Databases Databases and PHP Handling Exceptions

Attila Balog
Attila Balog
5,217 Points

Connection successfully.(every time)

$db = new PDO("sqlite:".DIR."/database.db"); may be i don't understand, but my thinking is: with this command we create a new DB and after that we connect to it. So you won't get any error messages because you connect to the newly created DB, and every time when you change the name of the DB (as i did) $db = new PDO("sqlite:".DIR."/databaseeeee.db"); $db = new PDO("sqlite:".DIR."/databasexxxx.db"); you create a new one and you connect to that one.(check it in your inc folder, all these db-s appears there) If i wrong please let me know. Thank you.

The same thing is happening to me. So how do we get the try/catch block to display output "Unable to connect"?

2 Answers

Thanks, I was wondering why I wasn't getting an error/exception!

Riki Tiilikainen
Riki Tiilikainen
4,042 Points

When I test it locally and break the connection, the same thing happens. Keeps creating new databases. Any idea why?