query($AssetUpdateSql); if ($AssetUpdateResult === TRUE) { $value = array( "AssetID"=>$AssetID, "IsInServiceCenter"=>(int)$IsInServiceCenter, "Message"=>"Asset data saved successfully", ); // Use json_encode() function $json = json_encode($value); }else { http_response_code(404); $errorMesage= $conn->error; // Declare an array with error message $value = array( "Message"=>"Something went wrong", "Error"=>$errorMesage ); // Use json_encode() function $json = json_encode($value); } // Display the output echo ($json); $conn->close();