What is wrong with this query?
#1

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;
}
Reply
#2

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));
Reply
#3

Whats the difference between mine and that code?
Reply
#4

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));
Reply
#5

Nope still get that error
Reply
#6

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)