Question: We use this type of filtering algorithm a lot for embedded machine control. Does anyone know a name for this type of algorithm? It is somewhat similar to a leaky-bucket algorithm.

Given the periodic occurrence of an event, this 'filtering' algorithm allows a ‘bad’ event to be “undone” by a subsequent ‘good’ event.
If there is an excess of bad events, then the filter triggers. The filter uses these variables:

* IsBadEvent – TRUE or FALSE status of the current event.
* Threshold – The number of excessive bad events that trigger the filter.
* NumBadEvents – Number of TRUE’s minus the number of FALSE’s.

---

* If IsBadEvent is TRUE, then increment NumBadEvents. /\* Add water to the bucket \*/
* If IsBadEvent is FALSE, then decrement NumBadEvents (to a floor of 0). /\* Bucket is leaking water \*/
* If NumBadEvents exceeds the Threshold, then trigger the filter. /\* Bucket overflows. \*/

Another use of the algorithm is by CAN bus to decide if it should go to ‘bus off’. In that case, the increments are 8 times the size of decrements. So it is biased toward failure (i.e., bus off) with still an allowance for ‘self-healing’.

Answer: 
Your UPDATE statement is wrong: 

```

    "UPDATE `contacts` SET email = '$email2' AND phone = '$number2' AND address = '$address2' AND name = '$name2' WHERE id = '$del_id'"

```

Try this instead
================

```
// Please sanitize the data
$email2 = filter_var( $email2, FILTER_SANITIZE_EMAIL );
$name2 = preg_replace( "#[^a-zA-Z ]#", '', $name2 );
$number2 = preg_replace( "#[^0-9 \-\+]#", '', $number2 );
$address = preg_replace( "[^\w \.\-\+]#", '', $address2 );

"UPDATE `contacts` SET email = '$email2', phone = '$number2', address = '$address2', name = '$name2' WHERE id = '$del_id' LIMIT 1"

```

Note
====

I added the limit clause `LIMIT 1` to limit the number of rows that will be affected by the update statement. In this case, am setting it to `1` to make sure we're updating a single row. Am sure you would want that also. 

**\* Please, consider using mysqli prepared query or PDO**
Replace your `$query` line. 

```
$query = "UPDATE `contacts` 
          SET email = '$email2', phone = '$number2', address = '$address2', name = '$name2' 
          WHERE id = '$del_id'";

```

`AND` can be used in `WHERE` clause.