Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Accept array from Form and put in DB

by peppiv (Curate)
on Dec 09, 2002 at 16:00 UTC ( #218559=note: print w/ replies, xml ) Need Help??


in reply to Accept array from Form and put in DB

Update
When I put two values into the array (e.g. @quantity = [2,1]), I get four entries into the DB. Two duplicates entries. Please help me understand my mistake. TIA


Comment on Re: Accept array from Form and put in DB
Download Code
(jeffa) 2Re: Accept array from Form and put in DB
by jeffa (Chancellor) on Dec 09, 2002 at 16:20 UTC
    The expression @quantity = [2,1] does not assign two values into the array, it instead assigns an anonymous array reference which contains two values into the array. Did you mean @quantity = (2,1) instead? Here is some more code to play with:
    use strict; use Data::Dumper; my @wrong = [2,1]; my @right = (2,1); my $ref = [2,1]; print 'right: ', Dumper \@right; print 'right: ', Dumper $ref; print 'wrong: ', Dumper \@wrong;
    Update: this is a common pitfall that probably all of us have stumbled on at least once ... i sure have!

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Yes, I did mean to type (2,1). I'm having a colorless day.

      I did enjoy your triplet paradiddle with high-hat. Fortunately being a guitar player, I only have to tap my foot, hold a single note and raise my pick hand in the air. (Hey I was an 80's rocker -> gimme a break).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://218559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-21 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (105 votes), past polls