PDO Exception don't catch
try{ line53 -> $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $ekle = $db->prepare("INSERT INTO data SET name=?, email=?"); $insert = $ekle->execute(array("$name","$e_mail")); if($insert) { header ("Location:sucess.html"); } else{ throw ("Error"); } } catch(PDOException $e){ echo $e->getMessage(); header ("Location:error.html"); } this code don't catch exception. SQL isn't work. Take error Notice: Undefined variable: db in C:\xampp\htdocs\.....\.....php on line 53 Fatal error: Call to a member function prepare() on null in C:\xampp\htdocs\.....\....php on line 53