[prev in list] [next in list] [prev in thread] [next in thread] 

List:       msqlperl
Subject:    RE: Trouble getting array from $sth->fetchrow
From:       frankd () gte ! net
Date:       1998-07-02 14:23:22
[Download RAW message or body]



> Hm.  Could you post the lines of code that you're using to
> check the values
> of the row data?  For example, are you saying:
> 	print "@row[3]\n";
> ?  Just guessing, but maybe there is a typo there?

This works fine it will print out all of the fields of data:

$query = "SELECT lat,lon,velocity,heading,hh,mm,ss,day,month,year FROM
gps_data";
$sth = $dbh->query($query)|| die "Unable to query database:
$Msql::db_errstr";
print $sth->fetchrow;

output-

27.95165-82.52608001012492698

This does not work so well, all I get in the array is the last field 'year'.
When I run perl with '-w' it gives me 'use of unitialized value' errors for
the empty fields in the array.

$query = "SELECT lat,lon,velocity,heading,hh,mm,ss,day,month,year FROM
gps_data";
print "$query\n";
$sth = $dbh->query($query)|| die "Unable to query database:
$Msql::db_errstr";
@row = ($sth->fetchrow)|| die "Unable to get results from query:
$Msql::db_errstr";
print
"$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$ro
w[9]\n";

output-

Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
Use of uninitialized value at ./find.pl line 35.
98,,,,,,,,,

The value '98' is the 'year' field in the table which should be the last
value.

----------------------------------------------------------------------
To unsubscribe from this list send a message containing "unsubscribe"
to msqlperl-request@franz.ww.tu-berlin.de

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic