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 Getting Started With PDO Connecting with PDO

Could not replicate the "Uncaught Exception" error created in the video.

Clearly something must have been changed in a recent software update. Maybe it's not that big a deal, but I find it disturbing that PDO happily creates a broken object created with a bad file name.

<?php

// Remove before flight
ini_set('display_errors', 'On');  // Turns on error responses

$db = new PDO('sqlite:./dataaabase.db');

var_dump($db);

die();

?>

No error. The result I get is the same as with the correct database file name: "object(PDO)#1 (0) { }"

2 Answers

Bryan Manhollan
PLUS
Bryan Manhollan
Courses Plus Student 7,861 Points

Workspaces has been updated since the video was created and will correct this to a degree. Instead try:

<?php

// Remove before flight
ini_set('display_errors', 'On');  // Turns on error responses

$db = new PDO('sqlite:../database.db');

var_dump($db);

die();

?>

Notice the extra "." before /database.db.

kabir k
kabir k
Courses Plus Student 18,036 Points

The 2 dots only helps to show the error. Once you correct the spelling, it still shows the error, unlike the teacher's code, it doesn't go back to showing the PDO object that was originally seen with the single dot.

kabir k
PLUS
kabir k
Courses Plus Student 18,036 Points

I think it has to do more with the error settings on one's computer, for it to work just like the teacher's.