More then one Mysql Query results in crash?
by Robin Rudick · in Torque Game Engine · 09/26/2006 (6:45 pm) · 0 replies
Im trying to create a simple system to store items inside the server while its waiting to slide in and out of the database, at the moment im in the phase that will be creating the players inventory at there first login after a server reset, and right now im running into an issue, the moment i call another mysql query within the same function, i get a crash?!
here is the script so far, still under development till i can get this functioning...
function serverCmdCreateInventory(%client, %UserID)
{
%Name = "IN" @ %UserID;
echo("InID: ", %Name);
new SimGroup(%Name){
Owner = %UserID;
};
%InDB = new MySQL();
%InDB.host = "127.0.0.1";
%InDB.port = "3306";
%InDB.user = "root";
%InDB.pwd = "";
%InDB.flag_compress = false;
%InDB.flag_ssl = false;
%InDB.db = "Torque";
%InDB.ValidateSettings();
%InDB.Connect();
%InDB.Query ("SELECT * FROM player_items WHERE UserID = \'" @ %UserID @ "\'");
%result = %InDB.StoreResult();
%amount = %InDB.NumRows(%result);
for (%i= 0; %i< %InDB.NumRows (%result); %i++)
{
%InDB.FetchRow (%result);
%Name.ItemID[%i] = %InDB.GetRowCell (%result, "ItemID");
%Name.ItemAmount[%i] = %InDB.GetRowCell (%result, "Amount");
echo("ItemID: ", %Name.ItemID[%i]);
echo("ItemAmount: ", %Name.ItemAmount[%i]);
}
%InDB.FreeResult (%result);
for (%n= 0; %n< %amount; %n++)
{
%ToCheck = %Name.ItemID[%n];
%InDB.Query ("SELECT * FROM items WHERE ItemID = \'" @ %ToCheck @ "\'");
%resultitem = %InDB.StoreResult();
%Name.ItemName[%n] = %InDB.GetRowCell (%resultitem, "ItemName");
}
%InDB.Close();
%InDB.FreeResult (%resultitem);
}
thanks for the help!
here is the script so far, still under development till i can get this functioning...
function serverCmdCreateInventory(%client, %UserID)
{
%Name = "IN" @ %UserID;
echo("InID: ", %Name);
new SimGroup(%Name){
Owner = %UserID;
};
%InDB = new MySQL();
%InDB.host = "127.0.0.1";
%InDB.port = "3306";
%InDB.user = "root";
%InDB.pwd = "";
%InDB.flag_compress = false;
%InDB.flag_ssl = false;
%InDB.db = "Torque";
%InDB.ValidateSettings();
%InDB.Connect();
%InDB.Query ("SELECT * FROM player_items WHERE UserID = \'" @ %UserID @ "\'");
%result = %InDB.StoreResult();
%amount = %InDB.NumRows(%result);
for (%i= 0; %i< %InDB.NumRows (%result); %i++)
{
%InDB.FetchRow (%result);
%Name.ItemID[%i] = %InDB.GetRowCell (%result, "ItemID");
%Name.ItemAmount[%i] = %InDB.GetRowCell (%result, "Amount");
echo("ItemID: ", %Name.ItemID[%i]);
echo("ItemAmount: ", %Name.ItemAmount[%i]);
}
%InDB.FreeResult (%result);
for (%n= 0; %n< %amount; %n++)
{
%ToCheck = %Name.ItemID[%n];
%InDB.Query ("SELECT * FROM items WHERE ItemID = \'" @ %ToCheck @ "\'");
%resultitem = %InDB.StoreResult();
%Name.ItemName[%n] = %InDB.GetRowCell (%resultitem, "ItemName");
}
%InDB.Close();
%InDB.FreeResult (%resultitem);
}
thanks for the help!