My code:
$sql = “SELECT * FROM bus170 limit 100”;
try {
$db->query($sql);
} catch (PDOException $e) {
echo $e->getMessage();
}
Why is there no error when I purposely use a nonexistent table name, using this code?
My code:
$sql = “SELECT * FROM bus170 limit 100”;
try {
$db->query($sql);
} catch (PDOException $e) {
echo $e->getMessage();
}
Why is there no error when I purposely use a nonexistent table name, using this code?
Have you enabled PDO exceptions? As I recall they are not enabled by default.
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
That’s it! Thank-you!
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.