#!/user/bin/perl -w
use CGI q~:standard~;
use CGI::Carp qw(fatalsToBrowser);
use strict;
use DBI;
print "Content-type: text/html\n\n";
my ($dbh, $sth, $haveimage, @games, @holder, $gallerynumber, $gallery, @imghold, @images,
$imagenumber, $image, $groupname, $test);
$haveimage = 'No';
$dbh = DBI -> connect ('dbi:ODBC:read', 'uid', 'pass') or die "$DBI::errstr;";
$sth = $dbh -> prepare (q~select table_name from FFImages.information_schema.tables where table_catalog = 'FFImages' and table_type = 'Base Table' and table_name != 'dtproperties' and table_name != 'avatars'~) or die "$DBI::errstr;";
$sth -> execute() or die "$DBI::errstr;";
while (@holder = $sth -> fetchrow_array){
@games = (@games, @holder);
}
do {
$gallerynumber = int(rand(@games));
$gallery = $games[$gallerynumber]; #There are 48 possible results for $Gallery
$sth = $dbh -> prepare (qq~select ImageName from FFImages.dbo.$gallery~) or die "$DBI::errstr;";
$sth -> execute() or die "$DBI::errstr;";
while (@imghold = $sth -> fetchrow_array){
@images = (@images, @imghold);
}
if ($images[0] ne ''){#Right now the only $gallery results that would return true here are 'ffac' and 'ffxi'
$imagenumber = int(rand(@images));
$image = $images[$imagenumber];
$sth = $dbh -> prepare(qq~select GroupName from FFImages.dbo.$gallery where ImageName = '$image'~) or die "$DBI::errstr;"; #Everything is working fine up to and including this part, after here no matter what was in $gallery it is not longer there
$sth -> execute() or die "$DBI::errstr;";
$groupname = $sth -> fetchrow_array;
print qq~
~; #At this point $gallery now contains 'ffxi' even if it did not before hand.
$haveimage = 'Yes';
}
} while ($haveimage ne 'Yes');
$dbh -> disconnect();
Can anyone tell me why $gallery is changed twords the end of the script when I never change it, at least I can not see it changing.
Just a wild guess - is there somewhere that is performing an arithmetic operation on the string? You might try logging your variables as the script runs, to determine where the change occurs.
perlmonks.org content © perlmonks.org and Eagle_f90, spiritway
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03