I'm not sure what you're trying to accomplish that leaving RaiseError off and PrintError on wouldn't accomplish. By checking only the execute() and not the prepare() you may, depending on the driver, be losing the actual cause of the error. Also, while $DBI::errstr should work in most situations you are better off using the errstr most closely associated with the object in questions, $dbh->errstr for prepare and other database handle methods $sth->errstr for execute and other statement handle methods.