The problem is NOT all exceptions are PDOExceptions
.You code cacthes only PDOException
which means new Exception
won't be catched. Try :
try
{
$stmt = $db->dbh->prepare("SELECT user FROM reset ");
...
}
catch (PDOException $e)
{
$error = new Errors();
echo "<b>".$error->displayError($e)."</b>";
}
catch (Exception $e)
{
$error = new Errors();
echo "<b>".$error->displayError($e)."</b>";
}
The reason why your code works when you spell SELECT
as SLECT
is because you triggered a PDOException
instead of a new Exception
.