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 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,863 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.