in reply to Fetching DB using a While loop.

my $sql = "select name,address,phone,email from my table where name='m +ary'"; my $sth=$dbh->prepare($sql) or die "Couldn't prepare statement handle: + ".$dbh->errstr(); my $count=$sth->execute() or die "Couldn't execute statement:".$dbh->e +rrstr(); while (my @row=$sth->fetchrow_array()) { $AoH{ alldata } = join (' ', @row); } $sth->finish();
But what is 'alldata'? The row inside the loop will continually overwrite its own results, I suspect you actually want something more like:
push(@some_array, join(' ', @row));
Oh, and of course, you'll be using placeholders in the real thing, right?
my $sql="select name,address,phone,email from my table where name=?"; my $sth=$dbh->prepare($sql) or die "Couldn't prepare statement handle: + ".$dbh->errstr(); my $count=$sth->execute('mary') or die "Couldn't execute statement:".$ +dbh->errstr();