Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 46
Trades: 0
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
 
 
Register now for full access!
Old 04-19-2007, 10:01 PM Re: PHP For Each (Unset?) Help
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
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:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP For Each (Unset?) Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.24345 seconds with 12 queries