MySQL syntax issue -
HighFlyer - 21.09.2012
Hello there,
I have modified my SaveOwnedCar stock, in order to allow proper updating of database records (previously it updated all fields and made them to 0 or default for some reason, and I'm hoping this way it will only update the selected fields), but somehow I get this weird syntax issue pop up on the console, when I start the server up. I have no idea where I'm going wrong.
Код:
stock SaveOwnedCar(iVehicleID) {
new
Query[1024],
buffer[160],
SQL_vOwner[MAX_PLAYER_NAME],
SQL_VehiclePlate[32];
mysql_real_escape_string(Vehicles[iVehicleID][VehicleOwner], SQL_vOwner);
mysql_real_escape_string(Vehicles[iVehicleID][VehiclePlate], SQL_VehiclePlate);
format(Query, sizeof(Query), "UPDATE `OwnedVehicles` SET `OwnedVehicleModel` = %i, `OwnedVehicleColor1` = %i, `OwnedVehicleColor2` = %i, `OwnedVehiclePrice` = %i, `OwnedVehicleOwner` = '%s', ",
Vehicles[iVehicleID][vModel],
Vehicles[iVehicleID][vColor1],
Vehicles[iVehicleID][vColor2],
Vehicles[iVehicleID][vPrice],
SQL_vOwner);
format(buffer, sizeof(buffer), "`OwnedVehicleX` = '%0.3f', `OwnedVehicleY` = '%0.3f', `OwnedVehicleZ` = '%0.3f', `OwnedVehicleA` = '%0.3f', `OwnedVehiclePlate` = '%s', ",
Vehicles[iVehicleID][vPosX],
Vehicles[iVehicleID][vPosY],
Vehicles[iVehicleID][vPosZ],
Vehicles[iVehicleID][vPosA],
SQL_VehiclePlate);
strcat(Query, buffer);
format(buffer, sizeof(buffer), "`OwnedVehiclePaintJob` = %i, `OwnedVehicleLock` = %i, `OwnedVehicleMoney` = %i, `OwnedVehicleMaterials` = %i, `OwnedVehicleCocaine` = %i, ",
Vehicles[iVehicleID][VehiclePaintJob],
Vehicles[iVehicleID][vLocked],
Vehicles[iVehicleID][vTrunkMoney],
Vehicles[iVehicleID][vTrunkMats],
Vehicles[iVehicleID][vTrunkCocaine]);
strcat(Query, buffer);
format(buffer, sizeof(buffer), "`OwnedVehicleMoonshine` = %i, `OwnedVehicleWeed` = %i,`OwnedVehicleFuel` = %d WHERE `OwnedVehicleID` = %i LIMIT",
Vehicles[iVehicleID][vTrunkMoonshine],
Vehicles[iVehicleID][vTrunkWeed],
Vehicles[iVehicleID][vFuel],
iVehicleID);
strcat(Query, buffer);
print(Query);
mysql_query(Query);
return 1;
}
The syntax message is this...
Код:
[20:27:27] 1064 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 -1 -1 NULL UPDATE `OwnedVehicles` SET `OwnedVehicleModel` = 451, `OwnedVehicleColor1` = 3, `OwnedVehicleColor2` = 3, `OwnedVehiclePrice` = 0, `OwnedVehicleOwner` = 'HighFlyer', `OwnedVehicleX` = '1643.530', `OwnedVehicleY` = '180.645', `OwnedVehicleZ` = '32.897', `OwnedVehicleA` = '348.498', `OwnedVehiclePlate` = 'ZZ57 OPP', `OwnedVehiclePaintJob` = 0, `OwnedVehicleLock` = 0, `OwnedVehicleMoney` = 0, `OwnedVehicleMaterials` = 0, `OwnedVehicleCocaine` = 0, `OwnedVehicleMoonshine` = 0, `OwnedVehicleWeed` = 0,`OwnedVehicleFuel` = 0 WHERE `OwnedVehicleID` = 2 LIMIT 1
But I've also printed this...
Код:
[20:27:27] UPDATE `OwnedVehicles` SET `OwnedVehicleModel` = 451, `OwnedVehicleColor1` = 3, `OwnedVehicleColor2` = 3, `OwnedVehiclePrice` = 0, `OwnedVehicleOwner` = 'HighFlyer', `OwnedVehicleX` = '1643.530', `OwnedVehicleY` = '180.645', `OwnedVehicleZ` = '32.897', `OwnedVehicleA` = '348.498', `OwnedVehiclePlate` = 'ZZ57 OPP', `OwnedVehiclePaintJob` = 0, `OwnedVehicleLock` = 0, `OwnedVehicleMoney` = 0, `OwnedVehicleMaterials` = 0, `OwnedVehicleCocaine` = 0, `OwnedVehicleMoonshine` = 0, `OwnedVehicleWeed` = 0,`OwnedVehicleFuel` = 0 WHERE `OwnedVehicleID` = 2 LIMIT
Re: MySQL syntax issue - HuSs3n - 21.09.2012
replace
with
Re: MySQL syntax issue -
HighFlyer - 21.09.2012
Oh, didn't notice again
There is however a problem with this, when I use my /savecar command to save the new position of the vehicle, some stats are reset to default, like OwnedVehiclePrice. Any offers?
Re: MySQL syntax issue -
mamorunl - 21.09.2012
is Vehicles[iVehicleID][vPrice] set properly?
Re: MySQL syntax issue -
HighFlyer - 21.09.2012
I'm pretty sure it is, it works on another command. I've changed to StrickenKid's plugin now, as I was advised that it might be a better solution, but I don't know why I'm getting these errors...
Код:
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1126) : error 017: undefined symbol "mysql_init"
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1126) : warning 213: tag mismatch
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1127) : warning 202: number of arguments does not match definition
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1127) : error 017: undefined symbol "auto_reconnect"
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1127) : warning 215: expression has no effect
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1127) : error 001: expected token: ";", but found ")"
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1127) : error 029: invalid expression, assumed zero
C:\Users\Kamil\Desktop\serwer\gamemodes\new.pwn(1127) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
5 Errors.
Код:
public OnGameModeInit()
{
hSQL = mysql_init(LOG_ONLY_ERRORS, 1);
new handle = mysql_connect(mysql_host, mysql_user, mysql_password, mysql_database, hSQL, .auto_reconnect=1);
if (!handle) return printf("No connection with MySQL database."), SendRconCommand("exit"), 0;
...rest of the public and return.
Adding the ; after auto_reconnect=1 returns errors.