Don't undef the username and password, rather pass empty strings.

Ilya

-----Original Message-----
From: Janakiram Koka [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, December 18, 2001 8:49 PM
To: [EMAIL PROTECTED]
Subject: getting selectall_hashref() to work


Hi,

I am trying to get the selectall_hashref() method to work.  I have a
table called "youthLeader", with columns "fname" and "lname".  I want to
retrieve all the rows in one shot and then output each row (eventually I
want to feed this to the looping construct in HTML::Template).  Any
clues as to what I'm doing wrong?

Here's my code...

my $dbh = DBI->connect("DBI:mysql:infomgr", undef, undef) or die "Can't
connect: " . $DBI::errstr;
my $matrix = $dbh->selectall_hashref("SELECT * FROM youthLeader"); print
"value 2 = " . $matrix->[1]{fname} . "\n"; $dbh->disconnect;

and here's the error message I'm getting...

[Tue Dec 18 20:29:39 2001] yltest.pl: Use of uninitialized value in hash
element at C:/Perl/site/lib/DBI.pm line 1205. [Tue Dec 18 20:29:39 2001]
yltest.pl: Use of uninitialized value in concatenation (.) or string at
C:/Perl/site/lib/DBI.pm line 1208. [Tue Dec 18 20:29:39 2001] yltest.pl:
DBD::mysql::db selectall_hashref
failed: Field '' does not exist (not one of fname lname) at yltest.pl
line 26. [Tue Dec 18 20:29:39 2001] yltest.pl: Use of uninitialized
value in concatenation (.) or string at yltest.pl line 27.

BTW, I'm using DBI v1.20 on ActiveState Perl 5.6.1.630 on Windows XP.

Thanks.

Jani

Reply via email to