new queryy[500];
mysql_format(mysql, queryy, sizeof(queryy), "REPLACE INTO `offsets` (`DisplayID`,`PosX0`,`PosY0`,`PosZ0`,`RotX0`,`RotY0`,`RotZ0`,`ScaleX0`,`ScaleY0`,`ScaleZ0`) VALUES ('%i',%f','%f','%f','%f','%f','%f','%f','%f','%f')", GetModelID(GetPVarInt(playerid, "edit")), fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ);
mysql_query(mysql, queryy);
SendClientMessage(playerid, -1, "Editing object");
RemovePlayerAttachedObject(playerid, 0);
If DisplayID exists, it will delete the old data and replace with the new instead of returning an error.
What you need is INSERT INTO .. ON DUPLICATE KEY UPDATE. Perhaps posting the error message? |
new queryy[500];
mysql_format(mysql, queryy, sizeof(queryy), "INSERT INTO `offsets` (`DisplayID`,`PosX0`,`PosY0`,`PosZ0`,`RotX0`,`RotY0`,`RotZ0`,`ScaleX0`,`ScaleY0`,`ScaleZ0`) VALUES ('%i',%f','%f','%f','%f','%f','%f','%f','%f','%f') ON DUPLICATE KEY UPDATE `PosX0` = '%f',`PosY0` = '%f',`PosZ0` = '%f',`RotX0` = '%f',`RotY0` = '%f',`RotZ0` = '%f',`ScaleX0` = '%f',`ScaleY0` = '%f',`ScaleZ0` = '%f'", GetModelID(GetPVarInt(playerid, "edit")), fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ, fOffsetX, fOffsetY, fOffsetZ, fRotX, fRotY, fRotZ, fScaleX, fScaleY, fScaleZ);
mysql_query(mysql, queryy);
SendClientMessage(playerid, -1, "Editing object");
RemovePlayerAttachedObject(playerid, 0);
C:\...\prp-gamemode.pwn(1767) : error 075: input line too long (after substitutions) C:\...\prp-gamemode.pwn(176 : error 017: undefined symbol "fOf" C:\...\prp-gamemode.pwn(1769) : error 017: undefined symbol "fsetX" C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : warning 215: expression has no effect C:\...\prp-gamemode.pwn(1769) : error 001: expected token: ";", but found ")" C:\...\prp-gamemode.pwn(1769) : error 029: invalid expression, assumed zero C:\..\prp-gamemode.pwn(1769) : fatal error 107: too many error messages on one line |
mysql_format(..., "...",
GetModelID(GetPVarInt(playerid, "edit")), ...);
After reading again what you were trying to do, I noticed that REPLACE was correct but INSERT INTO .. ON DUPLICATE is somewhat better. I did modify my post a couple of times, sorry about that.
So if you want to keep your old syntax, post the error in syntax you got even though the query seems ok. |
mysql_format - connection: 1, len: 500, format: "REPLACE INTO `offsets` (`DisplayID`,`PosX0`,`PosY0`,`PosZ0`,`RotX0`,`RotY 0`,`RotZ0`,`ScaleX0`,`ScaleY0`,`ScaleZ0`) VALUES ('%i',..." mysql_query - connection: 1, query: "REPLACE INTO `offsets` (`DisplayID`,`PosX0`,`PosY0`,`PosZ0`,`Rot", use_cache: true CMySQLQuery::Execute - starting query execution CMySQLQuery::Execute - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '','-0.019','0.0','0.0','88.5','0.0','1.0','1.0','1.0') ' at line 1 |
VALUES ('%i','%f','%f','%f','%f','%f','%f','%f','%f','%f')
The problem is clear now:
Код:
VALUES ('%i','%f','%f','%f','%f','%f','%f','%f','%f','%f') |