diff --git a/ludicrousdb/includes/class-ludicrousdb.php b/ludicrousdb/includes/class-ludicrousdb.php index c125dcd..07991a6 100644 --- a/ludicrousdb/includes/class-ludicrousdb.php +++ b/ludicrousdb/includes/class-ludicrousdb.php @@ -1833,9 +1833,16 @@ public function query( $query ) { // If there is an error then take note of it if ( $this->dbh_type_check( $this->dbh ) ) { $this->last_error = mysqli_error( $this->dbh ); + } else { + $this->last_error = __( 'Unable to retrieve the error message from MySQL' ); } if ( ! empty( $this->last_error ) ) { + // Clear insert_id on a subsequent failed insert. + if ( $this->insert_id && preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { + $this->insert_id = 0; + } + $this->print_error( $this->last_error ); $retval = false;