Hi all, hope some can help because this is giving me more grey hairs than I allready have.
I am trying to solve the following:
I'm pulling in JSON data, decoding it to a array which I write to a database. However in the array are social security numbers that I don't want to store (privacyregulations). So I need to check if a row has a social security number and if it has one I want to replace it with 'anonymized'.
I have got it to work successfully on a local Xampp test environment using the following script (extract off course):
//first anonymize the social security number (ssn) if exists
$data = json_decode($jsondata, true);
foreach($data as &$ssn){
if(!empty($ssn['ssn'])) {
$ssn['ssn']= '0';$ssn['ssn']= 'anonymized';
}
}
// then fill the tables
foreach($data as $row)
{
$insertstatement = mysqli_query($link,"INSERT INTO $tablename (personid, type, ssn) VALUES ('".$row["personid"]."', '".$row["type"]."', '".$row["ssn"]."') ON DUPLICATE KEY UPDATE type = VALUES(type), bsn = VALUES(ssn)");
}
This leads to a filled table where the ssn's are filled with 'anonymized' if they exist in the array and empty if it does not exist for that row. This is exactly what I want ;-).
Personid type ssn
1 a
2 a anonymized
3 b
4 a anonymized
However, when I run the same script on a Lamp production environment (lamp stack on an Azure server) it does not work. Then the scripts results in totally ignoring the whole row that contains a ssn??
Personid type ssn
1 a
3 b
Hope someone can help to get this working on my production environment as well.
Richard