Unable to Update MySQL record containing an implode array

The code works, if I am adding new entries in the database. But, if I try to run the update query, it fails. Not sure what I am doing wrong here. I am imploding the data in the allowances array. I have looked up other questions similar to this on stackoverflow; but, they did not quite match the issue that I am having.

Update.php code sample:

<?php
    
// Define variables and initialize with empty values
$name = $address = $allowances = "";
$name_err = $address_err = $allowances_err = "";
 
// Processing form data when form is submitted
if(isset($_POST["id"]) && !empty($_POST["id"])){
    // Get hidden input value
    $id = $_POST["id"];
    
    // Validate name
    $input_name = trim($_POST["name"]);
    if(empty($input_name)){
        $name_err = "Please enter a name.";
    } elseif(!filter_var($input_name, FILTER_VALIDATE_REGEXP, array("options"=>array("regexp"=>"/^[a-zA-Z\s]+$/")))){
        $name_err = "Please enter a valid name.";
    } else{
        $name = $input_name;
    }
    
    // Validate address address
    $input_address = trim($_POST["address"]);
    if(empty($input_address)){
        $address_err = "Please enter an address.";     
    } else{
        $address = $input_address;
    }
    
    // Validate allowances
    $input_allowances = "".((isset($_POST["allowances"]))?implode(", ",$_POST["allowances"]):"")."";
    if(empty($input_allowances)){
        $allowances_err = "Please enter the allowances amount.";     
    } elseif(!ctype_digit($input_allowances)){

Related posts