SA-MP Forums Archive
MySQL Update - 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: MySQL Update (/showthread.php?tid=613500)



MySQL Update - Shinja - 28.07.2016

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


Re: MySQL Update - Stuntff - 28.07.2016

mysql log please and witch mysql version you using ?


Re: MySQL Update - Shinja - 28.07.2016

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


Re: MySQL Update - Konstantinos - 28.07.2016

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


Re: MySQL Update - Shinja - 28.07.2016

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


Re: MySQL Update - Gforcez - 28.07.2016

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


Re: MySQL Update - Konstantinos - 28.07.2016

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.


Re: MySQL Update - Shinja - 28.07.2016

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


Re: MySQL Update - Konstantinos - 28.07.2016

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).


Re: MySQL Update - SyS - 28.07.2016

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'