H
Huub
Hi,
From some perl site I got this (changed some to fit my database):
$dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
$dbh = DBI->connect($dsn,$username,$password)
or die "Connection Error: $DBI::errstr\n";
$record = 101;
$sql = "select voorvoeg,naam from hvw where lidnr = $record";
$sth = $dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";
@row = $sth->fetchrow_array;
print "Naam: @row\n";
This works OK. However, when I put the lines "$sql = " and further in a
(while-)loop it doesn't do anything. Is this correct?
Also I have tried to read all database fields at once, but that didn't
work either, since "prepare" seems only to accept 1 parameter. How can I
do this effectively/efficiently?
Hints or directions on where to find this info are appreciated. Tried to
search on CPAN, but I don't know what to look for exactly.
Thanks for helping out,
Huub
From some perl site I got this (changed some to fit my database):
$dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
$dbh = DBI->connect($dsn,$username,$password)
or die "Connection Error: $DBI::errstr\n";
$record = 101;
$sql = "select voorvoeg,naam from hvw where lidnr = $record";
$sth = $dbh->prepare($sql);
$sth->execute or die "SQL Error: $DBI::errstr\n";
@row = $sth->fetchrow_array;
print "Naam: @row\n";
This works OK. However, when I put the lines "$sql = " and further in a
(while-)loop it doesn't do anything. Is this correct?
Also I have tried to read all database fields at once, but that didn't
work either, since "prepare" seems only to accept 1 parameter. How can I
do this effectively/efficiently?
Hints or directions on where to find this info are appreciated. Tried to
search on CPAN, but I don't know what to look for exactly.
Thanks for helping out,
Huub