I have a script for a form that takes all the names of the fields, uses a for each function to make my query short since there are a lot of fields. The problem is one of the fields uses AES_ENCRYPT, so it is alone in the query and not in the for each. The problem is I can't get it to not specify column ssn twice (thats my error).
Is there anyway I can omit it from the for each function?
My for each query
Quote:
foreach ($_POST as $key=>$value) {}...
DB Query
Quote:
// insert into database
$query = "INSERT INTO ".MYSQL_TBL_CLIENTS." SET $query_string, ssn='aes_encrypt($ssnpost, $aeskey)', lastupdate=NOW()";
Could just copy it all a local variable and unset that one:
PHP Code:
// Probably best to copy, leave superglobals alone $field_data = $_POST;
unset($field_data['ssn']);
foreach($field_data as $key=>$value) {}
// Do whatever with $_POST['ssn']
Note: Be careful with building queries this way. If it is something that is being used by end users, then it will be very easy to post more data to the script that shouldn't be there and inject SQL.