Jasmine wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi thanks .. for telling me tht DBI dont accept $! > erm i still have problems though. Theres actually data in the this table made > up of 2 columns. But, apparently my query keep returning "0" and "new" which > I cant understand why.
Hi Jasmine, Bob did explain the problem: > my $results = $query -> fetchrow_array; fetchrow_array returns an array, but you're calling in scalar context. If there's only one column, you need to call it like: my ($results) = $query->fetchrow_array; Since you have multiple columns, and you are not checking for errors with a die statement: my $results = $query->fetchrow_array or die "Assignment to \$results failed: $!"; You don't see the error produced when the fetchrow_array function is unable to properly assign its returned data. The point is, put parens () around your receiving fields to create an anonymous array. If your connection is sound--I don't see the code here--and the table and columns exist as named in your SQL, then this populates those fields. Another possiblity would be to assign it to an array directly: my @results = $query->fetchrow_array; and then assign the fields of that array to hash elements. The only purpose I could see to that is to get a field-count, my $field_count = @results; which you probably already have ;:-o). Or you could assume the table is fully populated, and that you want to display all results: my @results; my ($first, $second); while (($first, $second) = $query -> fetchrow_array()) { push @results, { 'first' => $first, 'second' => $second } } for (@results) { print "First = $_->{'first'}\t"; print "Second = $_->{'second'}\n"; } my $count = @results; print "Retreived $count records\n"; Let us know what result you get when you try this. You might also send more of the code, particularly the code you use to establish the DBI connection. Joseph Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]