Reply
PHP For Each (Unset?) Help
Old 04-19-2007, 09:46 PM PHP For Each (Unset?) Help
Experienced Talker

Posts: 46
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()";
bld44 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 04-19-2007, 10:01 PM Re: PHP For Each (Unset?) Help
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,320
Name: Keith Marshall
Location: West Hartford, CT
Can you show us your entire foreach loop?
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 04-19-2007, 10:52 PM Re: PHP For Each (Unset?) Help
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,111
Location: Toronto, Ontario
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.
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Reply     « Reply to PHP For Each (Unset?) Help
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11834 seconds with 12 queries