Hello ladies and gents, I seem to have run into an odd problem. I have written a simple script to pull some info from the database. Outside of the game, I can perfectly pull information at will with a junk "driver" line. In game, it stops. No response, no errors, no "quest::say..." commands, nothing.
Could anyone point out the stupid mistake I've made? It's always something like a variable name typo or line termination failure.
Code:
use DBI;
my (@arr, $sth, $instanceID);
my $db = "peq";
my $user = "root";
my $pass = "password";
my $host = "127.0.0.1";
my $dsn = "DBI:mysql:database=$db:host=$host";
my $dbh = DBI->connect ($dsn, $user, $pass);
sub CheckForInstance
{
#quest::say("Start CheckForInstance");
# try to find an instance ID in database
my $gID = $_[0];
my $zID = $_[1];
my $destroyOn;
my $timeLeft;
my $foundID;
my $foundDestroy;
my $instanceID;
my $var;
my $searchString = " SELECT id FROM instances WHERE guild = $gID AND zone = $zID ";
#quest::say("$searchString");
$sth = $dbh->prepare ($searchString);
$sth->execute();
while(@arr = $sth->fetchrow_array())
{
$instanceID = @arr[0];
$foundID = 1;
#quest::say("Found $instanceID belonging to $gID");
}
# release result set
$sth->finish();
if($foundID == 1)
{
# get the invite key end time
$searchString = "SELECT destroy FROM instances WHERE id = $instanceID";
$sth = $dbh->prepare($searchString);
$sth->execute();
# read data into appropriate variable(s)
@arr = $sth->fetchrow_array();
$destroyOn = @arr[0];
# clean for next query
$sth->finish();
} else
{
quest::say("Found nothing");
return "FALSE";
}
if(defined($destroyOn))
{
$searchString = "SELECT TIME_TO_SEC(TIMEDIFF('$destroyOn', NOW()))";
$sth = $dbh->prepare($searchString);
$sth->execute();
@arr = $sth->fetchrow_array();
#while(@arr = $sth->fetchrow_array())
#{
$timeLeft = @arr[0];
#printf "\n$timeLeft\n";
#}
# final release result set
$searchString = undef;
$sth->finish();
} else { $timeLeft = 0; }
# was an instance ID returned?
if(($instanceID > 0) && ($timeLeft > 0))
{
return $instanceID;
}
elsif($timeLeft <= 0)
{
return "EXPIRED";
}
else
{
return "FALSE";
}
}
Thank you so much preemptively!
-Hate