$sql = "INSERT INTO t1 (lsname) VALUES ('$lsname')"; $sth = $dbh->prepare( $sql ); $sth->execute; # here i want to print out a error message when the $sql could not be execute or met problem.