php - PDO error handling and storing errors in database -


how go getting pdo statements generate safe error message? don't want user see error message. want them directed page says clean message, "whoops unexpected happened!". log errors in database review , catch errors others generating.

i'm using php , mysql.

i found when make connection can set error handling this.

$dbh = new pdo($dsn, $user, $password); $dbh->setattribute(pdo::attr_errmode, pdo::errmode_exception); 

anyone before?

i think better write logs file, instead of database. since want log pdo errors, indicate wrong database connection.

you can show user nice error page catching errors. can redirect users error page then, in case went wrong.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -