MySQL Update
#1

PHP код:
SavePlayer(playerid)
{
    
CheckMySQL();
    new 
string[1056];
    
format(stringsizeof(string), "UPDATE 'Users' SET Kills = %d, Deaths = %d, Score = %d, Money = %d, Headshots = %d, Admin = %d, Vip = %d, Total Captures = %d, Highest Kill Spree = %d, Highest Cap Spree = %d WHERE Name = '%s'"pKills[playerid], pDeaths[playerid], GetPlayerScore(playerid), GetPlayerMoney(playerid), pHead[playerid], pAdmin[playerid], pVip[playerid], pTCap[playerid], pHSpree[playerid], pHCap[playerid], GetName(playerid));
    
mysql_query(string);
    return 
1;

Not saving, help
Reply
#2

mysql log please and witch mysql version you using ?
Reply
#3

Nothing in the logs, When i made it to save only Kills/deaths/score/money it worked
Reply
#4

As long as the column's name has space(s), wrap it around with grave accent like:
`Total Captures`
` Highest Kill Spree`
etc..
Reply
#5

Changed to
PHP код:
SavePlayer(playerid)
{
    
CheckMySQL();
    new 
string[1056];
    
format(stringsizeof(string), "UPDATE 'Users' SET 'Kills' = %d, 'Deaths' = %d, 'Score' = %d, 'Money' = %d, 'Headshots' = %d, 'Admin' = %d, 'Vip' = %d, 'Total Captures' = %d, 'Highest Kill Spree' = %d, 'Highest Cap Spree' = %d WHERE 'Name' = '%s'"pKills[playerid], pDeaths[playerid], GetPlayerScore(playerid), GetPlayerMoney(playerid), pHead[playerid], pAdmin[playerid], pVip[playerid], pTCap[playerid], pHSpree[playerid], pHCap[playerid], GetName(playerid));
    
mysql_query(string);
    return 
1;

Still not saving
Reply
#6

Код:
 `Highest Kill Spree` = %d, `Highest Cap Spree` = %d
You need ` instead of '
Reply
#7

That is apostrophe ' that you used which is incorrect, I said grave accent ` character. Just use it to those columns that have more than 1 word in the name, it is not needed to the rest.
Reply
#8

and
PHP код:
WHERE Name = `%s
? or..
Reply
#9

No, at column's name only. Specifiers (strings only) must have apostrophes such '%s' or '%e' (escaped).

And 'Users' for the table is incorrect. Either `Users` or Users (without anything).
Reply
#10

PHP код:
format(stringsizeof(string), "UPDATE Users SET Kills = %d, Deaths = %d, Score = %d, Money = %d, Headshots = %d, Admin = %d, Vip = %d, `Total Captures` = %d, `Highest Kill Spree` = %d, `Highest Cap Spree` = %d WHERE Name = '%s'"pKills[playerid], pDeaths[playerid], GetPlayerScore(playerid), GetPlayerMoney(playerid), pHead[playerid], pAdmin[playerid], pVip[playerid], pTCap[playerid], pHSpree[playerid], pHCap[playerid], GetName(playerid)); 
It should be like that ` on columns and ' on specifiers like '%s' and '%e'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)