SA-MP Forums Archive
My values aren't saving into SQL - 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: My values aren't saving into SQL (/showthread.php?tid=431228)



My values aren't saving into SQL - KiNG3 - 17.04.2013

Please delete, it's fixed!!! Thanks to everyone!


Re: My values aren't saving into SQL - Pottus - 17.04.2013

WHERE ID = %d" you have no reference to your id, I'm not sure how your system indexes users but I'm thinking it should look something like this

pawn Код:
stock savePlayer(playerid) {
    new
        szQuery[512]; // This is the only 512 strign exception, for our queries if we lower it... Then that won't be good...
    format(szQuery, sizeof(szQuery), "UPDATE `players` SET `Money` = '%d', `Score` = '%d', `Admin` = '%d', `Kills` = '%d', `Deaths` = '%d', `Weather` = '%d'", GetPlayerMoney(playerid), GetPlayerScore(playerid), PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pWeather]);
    format(szQuery, sizeof(szQuery), "%s, `Skin` = '%d', `Time` = '%d', `Color` = '%d', `Tele` = '%d', `Message` = '%d' WHERE `PlayerName` = '%s'", szQuery, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pTime], PlayerInfo[playerid][pColor], PlayerInfo[playerid][pColor], PlayerInfo[playerid][pTele], PlayerInfo[playerid][pMessage], ReturnName(playerid));

    mysql_query(szQuery, THREAD_NO_RESULT, playerid, iConnectionHandle);
    return 1;
}
That is to the best of my knowledge I've only used SQLITE but it should be something like that I gather.


Re: My values aren't saving into SQL - KiNG3 - 17.04.2013

before you replied, I noticed I forgot to define ID.... I did, and it still doesn't work... And ID is just to symbolize ID 1, ID 2, etc.


Re: My values aren't saving into SQL - Pottus - 17.04.2013

Well you were also missing a "," here Admin = %d Kills = %d,


Re: My values aren't saving into SQL - KiNG3 - 17.04.2013

Here, I edited my code a bit more and this is what it looks like now....


Re: My values aren't saving into SQL - RedCrossER - 17.04.2013

you forgot to put "," after Admin = %d

try this:
pawn Код:
format(szQuery, sizeof(szQuery), "UPDATE players SET Money = %d, Score = %d, Admin = %d, Kills = %d, Deaths = %d, Weather = %d", GetPlayerMoney(playerid), GetPlayerScore(playerid), PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pWeather]);



Re: My values aren't saving into SQL - KiNG3 - 17.04.2013

I did that, still not working unfortuantly. Check the main topic, i got a new message


Re: My values aren't saving into SQL - Pottus - 17.04.2013

Like I said originally, this "where ID =" doesn't seem right it should be something like "where `PlayerName` =


Re: My values aren't saving into SQL - KiNG3 - 17.04.2013

Well, I am using Calgon's basic MySQL
https://sampforum.blast.hk/showthread.php?tid=344978

And in the main source itself the line is this
pawn Код:
format(szQuery, sizeof(szQuery), "%s, Interior = %d, Skin = %d WHERE ID = %d", szQuery, playerVariables[playerid][pInterior], playerVariables[playerid][pSkin], playerVariables[playerid][pDBID]);



Re: My values aren't saving into SQL - Pottus - 17.04.2013

Alright I see why your doing that now try using the syntax I posted before.

format(szQuery, sizeof(szQuery), "UPDATE `players` SET `Money` = '%d', `Score` = '%d', `Admin` = '%d', `Kills` = '%d', `Deaths` = '%d', `Weather` = '%d'",