Use trace! (see the docs)

Tim.

On Mon, Dec 16, 2002 at 11:37:18AM -0500, chad kellerman wrote:
> Ney guys,
> 
>     I am trying to fetch and array form a table and I am not getting the
> results I thought I would get:
> 
> I thought it was quote simple but when I print them out....well you'll
> see?
> 
> 
> <code>
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> use DBI;
> 
> my( $dbname ) = "BACKUP";
> my( $mysqluser ) = "bob";
> my( $mysqlpasswd ) = "bobspasswd";
> my( $dbh, $sth, $rc, @failedCon, $var, $name, @names );
> 
> #these variables will be passed to subroutine in main program.
> my( $hostId ) = "543";
> my( $biggyFlag ) = "0";
> my( $hostDirFlag ) = "0";
> 
> 
> $dbh = DBI->connect( "DBI:mysql:database=".$dbname, $mysqluser,
> $mysqlpasswd ) or die "Cannot connect to database: $!";
> 
> #first check for failed attempts
> 
> $sth = $dbh->prepare( qq{ SELECT failedConAttempt FROM tblControl WHERE
> hostId="$hostId" } );
> $sth->execute;
> $sth->bind_columns( \$var );
> while  ( $sth->fetch ) {
> 
>     push @failedCon, $var;
> 
> }
> 
> print "backup failed to connect to $hostId: $failedCon[0] times.\n";
> 
> 
> #grab information
> 
> if ($failedCon[0] != 0 ) {
>         $sth = $dbh->prepare( q{
>                                 SELECT name FROM tblProcess
>                                 WHERE biggy_flag="$biggyFlag" AND
> hostId="$hostId" AND hostDirFlag="$hostDirFlag" AND status="In-Progress"
> OR status="Queued"
>                                 } );
>         $sth->execute;
>         $sth->bind_columns( \$name );
>         while ( $sth->fetch ) {
>             push @names, $name;
>             print "@names\n";
>         }
>     }else{
>         $sth = $dbh->prepare( q{
>                                 SELECT name FROM tblProcess
>                                 WHERE biggy_flag="$biggyFlag" AND
> hostId="$hostId" AND hostDirFlag="$hostDirFlag" } );
>         $sth->execute;
>                 $sth->bind_columns( \$name );
>         while ( $sth->fetchrow_array ) {
>             push @names, $name;
>             print "@names\n";
>         }
> 
>     }
> 
> $rc = $dbh->disconnect;
> 
> 
> </code>
> 
> 
> when I run this I get:
> 
> 
> [root@widowmaker sbin]# perl mysql.pl 
> backup failed to connect to 543: 5 times.
> alan
> alan alex
> alan alex bob
> alan alex bob cole
> alan alex bob cole brian
> alan alex bob cole brian coleman
> alan alex bob cole brian coleman david
> alan alex bob cole brian coleman david edward
> alan alex bob cole brian coleman david edward evilyn
> 
>   THe first print statemnet I get I expect, it came out right. But I
> just want to print the second array.. Why does it print
> alan
> alan alex
> alan alex bob
> alan alex bob cole
> alan alex bob cole brian
> alan alex bob cole brian coleman
> alan alex bob cole brian coleman david
> alan alex bob cole brian coleman david edward
> alan alex bob cole brian coleman david edward evilyn
> 
> and not just:
> alan alex bob cole brian coleman david edward evilyn
> 
> am I missing something???
> 
> Thanks,
> Chad
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> Chad Kellerman
> Jr. Systems Administrator
> Alabanza Inc
> 410-234-3305


Reply via email to