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 Managing Errors

my code does not get a "Fatal_Error" it creates a new file datadddbase.db. Why does it not fail?

<?php

// remove before flight (or send to production) ini_set('display_errors', 'On');

try { $db = new PDO('sqlite:./datadddbase.db'); var_dump($db); die(); } catch(Exception $e) { echo 'Sorry the connection was not successful'; die(); }

Gyver Vick
Gyver Vick
5,347 Points

I'm having the same problem using the following code. Can anyone provide some insight?

try {
  $db = new PDO('sqlite:./database.db');
  var_dump($db);
  die();
} catch(Exception $e) {
  echo "Sorry, the connection was not successful.";
  die();
}

Thanks Gyver Vick!!!

2 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

All the workaround does though is to create an error that the exception won't capture though so you'll get the standard php error. Best advice i can give for now is to follow the video along as closely as you can and if you get the list on the screen, that's the sign that the code is functional. :-)