01.09.2017, 01:14
I am getting the following error...
when executing this command...
As you can see, this command runs the query 'FactionCar_Create'
This successfully creates the car and saves it to the database, including the 'carFaction' value. The tables look like this...

So... if it's creating the car and also saving the carFaction value, why am I getting this error? Everything is working as it should.
Quote:
** [MySQL]: Unknown column 'carFaction' in 'field list' |
PHP код:
CMD:createfcar(playerid, params[])
{
static
model[32],
color1,
color2,
factionid;
if (PlayerData[playerid][pAdmin] < 4)
return SendErrorMessage(playerid, "You don't have permission to use this command.");
if (sscanf(params, "s[32]I(-1)I(-1)I(0)", model, color1, color2, factionid))
return SendSyntaxMessage(playerid, "/createfcar [modelid/name] [color1] [color2] [faction ID]");
if ((model[0] = GetVehicleModelByName(model)) == 0)
return SendErrorMessage(playerid, "Invalid model ID.");
static
Float:x,
Float:y,
Float:z,
Float:angle,
id = -1;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
id = FactionCar_Create(model[0], x, y, z + 1, angle, color1, color2, factionid, GetPlayerVirtualWorld(playerid));
if (id == -1)
return SendErrorMessage(playerid, "The server has reached the limit for dynamic vehicles.");
return 1;
}
PHP код:
FactionCar_Create(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, faction, world)
{
for (new i = 0; i != MAX_DYNAMIC_CARS; i ++)
{
if (!CarData[i][carExists])
{
if (color1 == -1)
color1 = random(127);
if (color2 == -1)
color2 = random(127);
CarData[i][carExists] = true;
CarData[i][carModel] = modelid;
CarData[i][carPos][0] = x;
CarData[i][carPos][1] = y;
CarData[i][carPos][2] = z;
CarData[i][carPos][3] = angle;
CarData[i][carColor1] = color1;
CarData[i][carColor2] = color2;
new str[8], query[400];
format(str, sizeof(str), "%s%s%d%d%s%s%s", LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], random(9), random(9), LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);
SetVehicleNumberPlate(i, str);
format(CarData[i][carPlate], 11, "%s", str);
CarData[i][carWorld] = world;
CarData[i][carFaction] = faction;
CarData[i][carVehicle] = CreateVehicle(modelid, x, y, z, angle, color1, color2, -1);
if (CarData[i][carVehicle] != INVALID_VEHICLE_ID) {
ResetVehicle(CarData[i][carVehicle]);
}
mysql_format(g_iHandle, query, sizeof(query), "INSERT INTO `factioncars` (carModel, carPosX, carPosY, carPosZ, carPosR, carColor1, carColor2, carPlate, carFaction, carWorld) VALUES(%d, %f, %f, %f, %f, %d, %d, '%s', %d, %d)",
CarData[i][carModel],
CarData[i][carPos][0],
CarData[i][carPos][1],
CarData[i][carPos][2],
CarData[i][carPos][3],
CarData[i][carColor1],
CarData[i][carColor2],
CarData[i][carPlate],
CarData[i][carFaction],
CarData[i][carWorld]
);
mysql_tquery(g_iHandle, query, "OnFactionCarCreated", "i", i);
return 1;
}
}
return -1;
}
forward OnFactionCarCreated(carid);
public OnFactionCarCreated(carid)
{
if (carid == -1 || !CarData[carid][carExists])
return 0;
CarData[carid][carID] = mysql_insert_id();
FactionCar_Save(carid);
return 1;
}
FactionCar_Save(carid)
{
static
query[900];
if (CarData[carid][carVehicle] != INVALID_VEHICLE_ID)
{
for (new i = 0; i < 14; i ++) {
CarData[carid][carMods][i] = GetVehicleComponentInSlot(CarData[carid][carVehicle], i);
}
}
format(query, sizeof(query), "UPDATE `playercars` SET `carModel` = '%d', `carOwner` = '%d', `carPosX` = '%.4f', `carPosY` = '%.4f', `carPosZ` = '%.4f', `carPosR` = '%.4f', `carColor1` = '%d', `carColor2` = '%d', `carPlate` = '%s', `carFaction` = '%d', `carWorld` = '%d', `carRank` ='%d' WHERE `carID` = '%d'",
CarData[carid][carModel],
CarData[carid][carPos][0],
CarData[carid][carPos][1],
CarData[carid][carPos][2],
CarData[carid][carPos][3],
CarData[carid][carColor1],
CarData[carid][carColor2],
CarData[carid][carPlate],
CarData[carid][carFaction],
CarData[carid][carWorld],
CarData[carid][carRank],
CarData[carid][carID]
);
return mysql_function_query(g_iHandle, query, false, "", "");
}

So... if it's creating the car and also saving the carFaction value, why am I getting this error? Everything is working as it should.