in reply to DBI and fetching data

$i++ while $output[$i] = [ $sql->fetchrow_array ];

That loop never terminates. A reference is *always* true, even a reference to an empty array. However, you could write something like (I don't have DBI on the machine I'm currently working on, so this is untested):

my $output = $sql -> fetchall_arrayref; # Or my @output = @{$sql -> fetchall_arrayref};

If you are going to collect all results in a big array, let the DBI do the work for you.

Abigail

Replies are listed 'Best First'.
Re: Re: DBI and fetching data
by Melly (Chaplain) on Sep 12, 2003 at 09:09 UTC

    That looks good - I've only just dipped my toes into DBI, looks like it's time to get soaked.

    Just out of curiousity (I'm happy enough to roll my own), are there any good modules for working with CGI and DBI? (i.e. nicely formatted html tables of returned data in one easy go).

    Tom Melly, tom@tomandlu.co.uk
      nicely formatted html tables of returned data in one easy go

      Sure. Have a look at jeffa's DBIx::XHTML_Table. It does exactly what you want.