Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Database Output
by moritz (Cardinal) on Oct 11, 2010 at 15:43 UTC | |
by Anonymous Monk on Oct 11, 2010 at 15:57 UTC | |
by moritz (Cardinal) on Oct 11, 2010 at 16:42 UTC | |
|
Re: Database Output
by locked_user sundialsvc4 (Abbot) on Oct 11, 2010 at 16:37 UTC | |
|
Re: Database Output
by Anonymous Monk on Oct 11, 2010 at 20:37 UTC |