Dear Monks,

I have a quick question regarding how to convert data from 2 db fields into scalars.

my $Cookie1 = $cgi->cookie('C1'); my $Cookie2 = $cgi->cookie('C2'); my ($f1, $f2); if (cookie('C2')) { # found a cookie! my $sth = $dbh->prepare("SELECT field_1, field_2 FROM tablename WHE +RE field_3='?'") or "Error"; $sth->execute(cookie('C2')) or "Error"; if (my $rec = $sth->fetchrow_hashref) { $Cookie2 = cookie('C2'); $f1 = $rec->{field_1}; $f2 = $rec->{field_2};

Or do I need to repeat this for each field:

if (my $rec = $sth->fetchrow_hashref) { $Cookie2 = cookie('C2'); $f1 = $rec->{field_X};


In reply to Database Output by Anonymous Monk

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.