I see you are using :-
I use
PERL for
SQL, MySQL
In which I use a $dbh->errstr Example:-
$sth->execute or &sql_error_message("Can't open Could not execute SQL statement it maybe invalid. errstr==>" . $dbh->errstr); # dienice ("Can't open Could not execute SQL statement it maybe invalid");
The sub-routine emails me with any error.
I bet
PHP has similar