SA-MP Forums Archive
[HELP] MYSQL Not save data - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] MYSQL Not save data (/showthread.php?tid=642508)



[HELP] MYSQL Not save data - MasterCodez - 01.10.2017

Код:
					new str[128];
					format(str, sizeof(str), "UPDATE `playeraccounts` SET pSpawnPosX='%f', pSpawnPosY='%f', pSpawnPosZ='%f', pSpawnPosFacing='%f', pSpawnSaved='1', pMoney -='500' WHERE pID='%d'", pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], PlayerInfo[playerid][pID]);
					mysql_query(Connection, str);
What wrong with this code?


Re: [HELP] MYSQL Not save data - m4karow - 01.10.2017

you should check the log folder before make a topic for this


Re: [HELP] MYSQL Not save data - whadez - 01.10.2017

Check log folder, and try to increase the 'str' variable's lenght, because I feel like with all of those float number's it'll overflow the lenght.


Re: [HELP] MYSQL Not save data - 10MIN - 01.10.2017

I think that you should change the lenght of the string to 196.

Measured with http://www.lettercount.com/, text:
Quote:

UPDATE `playeraccounts` SET pSpawnPosX='1111.111111', pSpawnPosY='1111.111111', pSpawnPosZ='1111.111111', pSpawnPosFacing='1111.111111', pSpawnSaved='1111.111111', pMoney -='500' WHERE pID='999'




Re: [HELP] MYSQL Not save data - MasterCodez - 02.10.2017

Код:
[10:43:44] [ERROR] CMySQLQuery::Execute - (error #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 '-='500' WHERE pID='3'' at line 1
Sorry, I newbie, help pls


Re: [HELP] MYSQL Not save data - biker122 - 02.10.2017

The negation operator (-) is probably causing this, try:
pawn Код:
new str[128];
                    format(str, sizeof(str), "UPDATE `playeraccounts` SET pSpawnPosX='%f', pSpawnPosY='%f', pSpawnPosZ='%f', pSpawnPosFacing='%f', pSpawnSaved='1', pMoney ='500' WHERE pID='%d'", pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], PlayerInfo[playerid][pID]);
                    mysql_query(Connection, str);



Re: [HELP] MYSQL Not save data - SyS - 02.10.2017

Compound operators would not work in SQL.Use pMoney = pMoney - 500
Make your string larger.(200 would be enough)
Don't use quotes (' ') around field values that are not string that just provide extra overhead to parse data.

PHP код:
new str[200];
format(strsizeof(str), "UPDATE `playeraccounts` SET pSpawnPosX=%f, pSpawnPosY=%f, pSpawnPosZ=%f, pSpawnPosFacing=%f, pSpawnSaved=1, pMoney = pMoney - 500 WHERE pID=%d"pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], PlayerInfo[playerid][pID]);
mysql_query(Connectionstr); 
Also only update things that really need an "update"


Re: [HELP] MYSQL Not save data - MasterCodez - 02.10.2017

Quote:
Originally Posted by SyS
Посмотреть сообщение
Compound operators would not work in SQL.Use pMoney = pMoney - 500
Make your string larger.(200 would be enough)
Don't use quotes (' ') around field values that are not string that just provide extra overhead to parse data.

PHP код:
new str[200];
format(strsizeof(str), "UPDATE `playeraccounts` SET pSpawnPosX=%f, pSpawnPosY=%f, pSpawnPosZ=%f, pSpawnPosFacing=%f, pSpawnSaved=1, pMoney = pMoney - 500 WHERE pID=%d"pPickInfo[i][dXe], pPickInfo[i][dYe], pPickInfo[i][dZe], pPickInfo[i][dAe], PlayerInfo[playerid][pID]);
mysql_query(Connectionstr); 
Also only update things that really need an "update"
Thank a lot