$answer = $sth->execute(); if($answer) { $sth->finish if $sth; } else { $mailbody .= "Cannot insert: ".$dbh->errstr."\n"; }