In DBI, I want to get the user input and fetch the rows given by user. I am getting only the last row of my table. But when i view it in MYSQL driver it shows all the rows.
Can anyone tell where i am wrong. This is the coding which i executed.
use DBI;
use strict;
$a=<STDIN>;
chomp $a;
$b=<STDIN>;
chomp $b;
my $dbname="test";
my $dbh=DBI->connect("DBI:mysql:$dbname","root","", {RaiseError=>1, Au
+toCommit=>0});
$sth=$dbh->do("create table rec(name varchar(10), id int(10)");
$sth=$dbh->prepare("insert into rec(name, id) values(?, ?)");
$sth->execute($a, $b);
$sth->prepare("select * from rec");
my @row;
while (@row=$sth->fetchrow_array)
{
print "@row\n";
}
$sth->finish();
$dbh->disconnect();
exit;
Thanks for the help. Apologize if any errors.
20060711 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips