$query = "UPDATE....
mysqli_query($conn,'START TRANSACTION');
$sql = mysqli_query($conn, $query);
$err_txt=mysqli_error($conn);
if($err_txt) { mysqli_query($conn,'ROLLBACK'); die($err_txt); }
$last_id = mysqli_insert_id($conn);
mysqli_query($conn,'COMMIT');