MCMULLIN, NANCY [mailto:[EMAIL PROTECTED] wrote:
> 
> Here's the easiest question you've had all day ;-)
> I'm attempting to retrieve values and pass them to another program.  But
> I'm only able to grab and save the first value. What do I have wrong?
> 
> CODE snippet:
>   my $sth = $dbh->prepare("SELECT field1, field2 FROM table WHERE field1
> = '$p1'")
>       or die "Preparing: ", $dbh->errstr;
>    $sth->execute or die "Executing: ", $sth->errstr;
>    while (my $row = $sth->fetchrow_arrayref())
>    {
>       print Tr( td( $field1, $field2 ) );
>       # note - I can print both values here
>   }

Your code sample does not appear to be complete.  I do not see how the
values get into $field1 and $field2.

BTW, you should be using placeholders rather than interpolating $p1 directly
into your SQL statement.  You are opening yourself up to SQL injection
attacks.

my $sth =
  $dbh->prepare("SELECT field1, field2 FROM table WHERE field1 = ?")
    or die "Preparing: ", $dbh->errstr;
$sth->execute($p1) or die "Executing: ", $sth->errstr;

Ronald


Reply via email to