Error (0): Failed to exeute 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 ''15.374' at line 1.
stock SavePlayerData(playerid)
{
new query[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
GetPlayerPos(playerid, PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z]);
format(query, sizeof(query), "UPDATE accounts SET Name = '%s', Password = '%s', Money = '%d', PlayerX = '%f', PlayerY = '%f', PlayerZ = '%f' WHERE Name = '%s'",
PlayerInfo[playerid][pName],
PlayerInfo[playerid][pPw],
PlayerInfo[playerid][pMoney],
PlayerInfo[playerid][pPos_x],
PlayerInfo[playerid][pPos_y],
PlayerInfo[playerid][pPos_z],
pname
);
mysql_query(query);
}
"UPDATE accounts SET Name = '%s',
"UPDATE `accounts` SET `Name` = '%s',
print(query);
UPDATE accounts SET Name = 'LongUserName_asdasdsdfra', Password = 'AVerylongpasswordOrMD5?20381039812038120381029381029', Money = '100000', PlayerX = '10.00000', PlayerY = '10.00000', PlayerZ = '10.00000' WHERE Name = 'LongUserName_asdasdsdfra'
''15.374' You're not closing the quotation. One quotation from the error and the 2nd one is yours.
Also, enclose your identifiers with a back tick ( ` ). Here's an example: Код:
"UPDATE accounts SET Name = '%s', Код:
"UPDATE `accounts` SET `Name` = '%s', |
If you don't know how to use MySQL, then don't even try. Go read up on writing a proper MySQL query before you start coding a whole system.
You don't need apostrophe's around all non-string placeholders. Where you have '%d' it should be %d- the same goes for %f, %i, %x, etc. The only time you should surround a placeholder in an apostrophe is if it's a string (i.e. %s). |
Apostrophes around all placeholders is completely valid and makes code more organized, along with the wrapping of column names in `.
|
Error (0): Failed to exeute 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 ''15.4' at line 1.
PlayerX float(7,4) PlayerY float(7,4) PlayerZ float(7,4)