I have this block of code:
try {
$dbh = new PDO('mysql:host='.$db_host.';dbname='.$db_database, $db_user, $db_pass);
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$dbh->prepare('DELECT userID FROM tblusers');
} catch (PDOException $e) {
echo "Error!: " . $e->getMessage() . "<br/>";
file_put_contents('PDOErrors.txt', $e->getMessage(), FILE_APPEND);
}
When I step through the code using the debugger in my IDE, it never enters into the catch
block even though I have an error in my prepare
statement.
What am I doing wrong?
I'm new to PDO and try/catch blocks so bear with me here if this is a dumb question!