[05/05/2011 16:06:07] [MySQL] Error (0): Function: mysql_fetch_field called when no result stored.
It means you probably called the function mysql_fetch_field after mysql_free_result was called.
Код HTML:
stock loadVehicles() //get vehicles from database and set their plates - called in OnGameModeInit()
{
new num;
mysql_query("SELECT a.*, b.userLevel,(select regionMain from regions where regionOLX<=a.vehicleX AND regionURX>=a.vehicleX AND regionURY<=a.vehicleY AND regionOLY>=a.vehicleY ORDER BY regionID DESC LIMIT 1)as region FROM vehicles as a, user_info as b WHERE a.vehicleOwnerID=b.userID ORDER BY `a`.`vehicleID` ASC;", -1, -1, MySQLConnection);
mysql_store_result(MySQLConnection);
num = mysql_num_rows(MySQLConnection);
if(num > 0)
{
new mysqlresult[512], keysresult[128], query[128], ownerlevel;
while(mysql_fetch_row(mysqlresult,"|",MySQLConnection)==1)
{
new id = GetMySQLField_Int("vehicleID", MySQLConnection);
if(id<MAX_CARS)
{
carInfo[id][ID] = id;
carInfo[id][modelID] = GetMySQLField_Int("vehicleModelID", MySQLConnection);
carInfo[id][companyID] = GetMySQLField_Int("vehicleCompanyID", MySQLConnection);
carInfo[id][ownerID] = GetMySQLField_Int("vehicleOwnerID", MySQLConnection);
carInfo[id][carX] = GetMySQLField_Float("vehicleX", MySQLConnection);
carInfo[id][carY] = GetMySQLField_Float("vehicleY", MySQLConnection);
carInfo[id][carZ] = GetMySQLField_Float("vehicleZ", MySQLConnection);
carInfo[id][carRot] = GetMySQLField_Float("vehicleRotation", MySQLConnection);
carInfo[id][colorMain] = GetMySQLField_Int("vehicleColor1", MySQLConnection);
carInfo[id][colorSub] = GetMySQLField_Int("vehicleColor2", MySQLConnection);
carInfo[id][carFuel] = GetMySQLField_Float("vehicleFuel", MySQLConnection);
carInfo[id][carKM] = GetMySQLField_Float("vehicleKM", MySQLConnection);
carInfo[id][locked]=true;
ownerlevel = GetMySQLField_Int("userLevel", MySQLConnection);
new string[3];
format(string,sizeof(string),"%s",GetMySQLField("region", MySQLConnection));
carInfo[id][carPlateRegion]=string;
carInfo[id][systemID] = CreateVehicle(carInfo[id][modelID], carInfo[id][carX], carInfo[id][carY], carInfo[id][carZ], carInfo[id][carRot], carInfo[id][colorMain], carInfo[id][colorSub], 0);
SetPlate(id,ownerlevel);
SetVehicleHealth(carInfo[id][systemID], GetMySQLField_Float("vehicleHealth", MySQLConnection));
format(query, sizeof(query), "SELECT userID FROM vehicle_keys WHERE vehicleID=%d", id);
mysql_query(query, -1, -1, MySQLConnection);
mysql_store_result(MySQLConnection);
if(mysql_num_rows(MySQLConnection)>0)
{
new i=0;
while(mysql_fetch_row(keysresult, "|", MySQLConnection) && i < sizeof(carKeys[]))
{
carKeys[id][i] = GetMySQLField_Int("userID", MySQLConnection);
i++;
}
}
mysql_free_result(MySQLConnection);
carsCount++;
}
}
}
mysql_free_result(MySQLConnection);
printf("[CAR] Load Cars: %d/%d loaded!",carsCount,num);
return 1;
}
That's an advanced query you got there.
The tables exist.
pawn Код:
mysql_query(query, -1, -1, MySQLConnection);
mysql_store_result(MySQLConnection);
if(mysql_num_rows(MySQLConnection)>0)
{
new i=0;
while(mysql_fetch_row(keysresult, "|", MySQLConnection) && i < sizeof(carKeys[]))
{
carKeys[id][i] = GetMySQLField_Int("userID", MySQLConnection);
i++;
}
}
This is the part that fails.
You will have to re-write this function because you can't store 2 results.