Subject: Array problem
To: [EMAIL PROTECTED]
From: "Chris Saunders" <[EMAIL PROTECTED]>
Date sent: Fri, 6 Jul 2001 15:08:36 +0000
> This might not strictly be a DBI problem so I apologise in advance.
>
> I'm writing an enquiry form and want to have some dropdown lists built from the DB
>so I'm doing a select and then assigning it to an array
> using push - sample code below...
>
> while (@data = $sth->fetchrow_array())
> {
> push (@cc,@data);
> }
>
> The problem I've got is I can print the values of the new array in IE but not
>Netscape and I can't see why. Does Netscape have some
> sort of limit coz one of the selects is getting aound 6500 elements.
elements or rows ??? with your code above, every fetched @data will
be flattened out into @cc, so
scalar @cc != number_of_selected_rows
but
scalar @cc = scalar( @data ) * number_of_selected_rows.
Your code only seems to make sense to me if @data contains only one
element, if not, the elements of @cc will represent different items
of the original table...
>
> I'd appreciate any help you can give me coz I've been stuck on this for about 2 days.
>
Your question seems better suited for the CGI list.
I have tested MSIE 5.5 and Netscape 4.7 with the code snippet below
<perlcode>
#!/usr/bin/perl
use warnings;
use strict;
use vars qw();
my $end = '<testvalue_here'>;
use CGI;
my $q = new CGI;
my @values = (1..$end);
print $q->header,
$q->start_html(),
$q->start_form,
$q->popup_menu(-name => test, -values => \@values),
$q->end_form,
$q->end_html;
</perlcode>
Both browsers did it with $end = 10000, but with $end = 100000
MSIE 5.5 displayed an empty list, and Netscape displayed a list till
element 32767 (signed int? seems to be the upper limit). Thus, both
browsers will display a list of 6500 elements without problems. As
pointed out above, your code flattens out the returned rows into your
array @cc, so you will reach Netscape's limit with 6500 rows if each
row contains more than 5 columns. However, I guess that your problem
is invalid HTML syntax somwhere in your output, which is tolerated by
MSIE, but not by Netscape. You can test this by commenting yout the
fetch_array()ing while-loop and hardcoding @cc = ('foo', 'bar'). I
would not be surprised if Netscape still would not work.
HTH
Bodo
[EMAIL PROTECTED]