query($AssetInsertSql); if ($AssetInsertresult === TRUE) { $value = array( "AssetID"=>$AssetID, "AssetName"=>$AssetName, "AssetCategoryID"=>$AssetCategoryID, "IsInServiceCenter"=>$IsInServiceCenter, "Message"=>"Data saved successfully", ); // Use json_encode() function $json = json_encode($value); }else { http_response_code(404); $errorMesage= $conn->error; $value = array( "Message"=>"Something went wrong", "Error"=>$errorMesage ); // Use json_encode() function $json = json_encode($value); } // Display the output echo ($json); $conn->close();