Here's something I haven't been able to figure out (but have to, urgently).
I have this e-commerce package on our site and since I'm running the CC verification through a socket program I wrote, I also want to send this information to a DB for reporting purposes (the commerce package sucks, but alas, I don't get to make purchasing recs).
Here's the problem: The commerce program sends me transaction details through a form. Their form sends (1) transaction info - name, time, etc. (2) and transaction details - quantity 1 of product B, quantity 2 of product C, etc. Their form iterates through the transaction details, if there's more than one item per transaction, and sends the data to my program. The data is sent through set variables but as the program iterates over to the next item, it sends the info again to the same variables. Hence, if I do a single DBI INSERT I'm only collecting info on the Last item.

I thought that using a while loop might solve this problem but I'm not sure if it's the right thing to do or I've just totally screwed it up :0

inoperative code to follow

my $sql2 = qq/ INSERT INTO transaction_details (quantity, gross_sales) VALUES ($ +quantity, convert (money, $gross_sales)) /; while (<>) { my $quantity = param("quantity"); $quantity = $dbh->quote( $quantity ); my $gross_sales = param("gross_sales"); $gross_sales = $dbh->quote( $gross_sales ); my $rv = $dbh->do( $sql2 ); }
I get no errors. I just know that I'm not passing any data to this table (I pass other data to another table earlier in the program so I'm sure the DB connection works). Can I accept variables passed through a form to this script in a while statement?

Any suggestions or quick pointers to where I'm falling down would be appreciated.

Supa Thanx, for any help

peppiv


In reply to DBI SQL statement in while loop by peppiv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.