try { $db = new PDO("mysql:host=localhost;dbname=test;charset=utf8", "root", "123456"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die($e->getMessege()); }