[HELP] MYSQL Not save data
#1

Код:
					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?
Reply
#2

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

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.
Reply
#4

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'

Reply
#5

Код:
[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
Reply
#6

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

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"
Reply
#8

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)