What is wrong with this query? -
iTorran - 14.11.2010
Hello,
Im trying to move my privatecars script onto MySQL,
So first of all i made a command which will save them all onto MySQL,
So i went ingame and did "/mysql_save" and then went on MySQL,
And well the vehicle was on there but the X, Y, Z, Angle, Model was 0
Then i looked at the console and i got:
Код:
[21:21:55] Error in mysql_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
So if you could tell me whats wrong with this query that would really help
pawn Код:
CMD:mysql_save(playerid, params[])
{
new Float:x, Float:y, Float:z, Float:a;
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleZAngle(vehicleid, a);
GetVehiclePos(vehicleid, x, y, z);
format(query, sizeof(query), "INSERT INTO `vehicles` (VehID, VehOwner) VALUES ('%d', '%s')", GetPlayerVehicleID(playerid), GetName(playerid));
samp_mysql_query(query);
format(query, sizeof(query), "UPDATE `vehicles` SET `VehModel` = %d, `VehX` = %f, `VehY` = %f, `VehZ` = %f, `VehA` = %f WHERE `VehID` = '%d'", GetVehicleModel(vehicleid), x, y, z, a, GetPlayerVehicleID(playerid));
samp_mysql_query(query);
return 1;
}
Re: What is wrong with this query? -
smeti - 14.11.2010
Try:
pawn Код:
format(query, sizeof(query), "UPDATE `vehicles` SET `VehModel` = '%d', `VehX` = '%f', `VehY` = '%f', `VehZ` = '%f', `VehA` = '%f' WHERE `VehID` = '%d'", GetVehicleModel(vehicleid), x, y, z, a, GetPlayerVehicleID(playerid));
Re: What is wrong with this query? -
iTorran - 14.11.2010
Whats the difference between mine and that code?
Re: What is wrong with this query? -
smeti - 14.11.2010
Quote:
Originally Posted by iTorran
Whats the difference between mine and that code?
|
Код:
format(query, sizeof(query), "UPDATE `vehicles` SET `VehModel` = %d, `VehX` = %f, `VehY` = %f, `VehZ` = %f, `VehA` = %f WHERE `VehID` = '%d'", GetVehicleModel(vehicleid), x, y, z, a, GetPlayerVehicleID(playerid));
Код:
format(query, sizeof(query), "UPDATE `vehicles` SET `VehModel` = '%d', `VehX` = '%f', `VehY` = '%f', `VehZ` = '%f', `VehA` = '%f' WHERE `VehID` = '%d'", GetVehicleModel(vehicleid), x, y, z, a, GetPlayerVehicleID(playerid));
Re: What is wrong with this query? -
iTorran - 14.11.2010
Nope still get that error
Re: What is wrong with this query? -
Fezq - 14.11.2010
Maybe try another way, something like that:
Код:
format(query, sizeof(query), "INSERT INTO `vehicles` SET VehID='%d', VehOwner='%s'", GetPlayerVehicleID(playerid), GetName(playerid));
samp_mysql_query(query);