MYSQL Getting and inserting
#2

Well FIRST of all you need to actually add an extra column in the MySQL table, did you add that yet? You generally use some sort of MySQL manager to sort things like that out, it makes things a lot easier and quicker, something like PhpMyAdmin or my favorite, Navicat.

Then you need to update your queries, for example if you added a new column to your table called "cow", you would update this query like so:

pawn Code:
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `kills` = %d, `deaths` = %d, `money` = %d, `Level` = %d, `Last Pos X` = %f, `Last Pos Y` = %f, `Last Pos Z` = %f, `Interior` = %d, `cow` = %d WHERE `user` = '%s'", // Also remember to update this...

        PVar[playerid][pKills],
        PVar[playerid][pDeaths],
        GetPlayerMoney(playerid),
        PVar[playerid][pLevel],
        PVar[playerid][pLastX],
        PVar[playerid][pLastY],
        PVar[playerid][pLastZ],
        GetPlayerInterior(playerid),
        PVar[playerid][cow],
        pName(playerid));
Additionally you need to create that extra variable in the enumeration.

Finally you need to modify your sscanf structure a bit for stripping the code and storing them in the assorted variables, so using the same example, it would need to be:

pawn Code:
sscanf(Query, "e<p<|>s[24]s[35]ddddfffdd>", PVar[iPlayer]);
It even happens to tell you in the code you pasted what you need to update, we add an extra d to that sscanf function to ensure that the new field you added is split from the query string and stored.

It really isn't difficult to understand, I recommend you read the official Pawn language documentation on the CompuPhase website, and some MySQL documentation on their official website. Having simple knowledge of what the functions are doing will make it very easy for you to dynamically write your own code and understand it.
Reply


Messages In This Thread
MYSQL Getting and inserting - by AlExAlExAlEx - 20.02.2011, 15:14
Re: MYSQL Getting and inserting - by JaTochNietDan - 21.02.2011, 19:06
Re: MYSQL Getting and inserting - by AlExAlExAlEx - 21.02.2011, 19:11
Re: MYSQL Getting and inserting - by JaTochNietDan - 21.02.2011, 19:20
Re: MYSQL Getting and inserting - by AlExAlExAlEx - 21.02.2011, 20:21
Re: MYSQL Getting and inserting - by JaTochNietDan - 21.02.2011, 20:34
Re: MYSQL Getting and inserting - by AlExAlExAlEx - 21.02.2011, 20:41
Re: MYSQL Getting and inserting - by JaTochNietDan - 21.02.2011, 20:57
Re: MYSQL Getting and inserting - by AlExAlExAlEx - 21.02.2011, 20:59
Re: MYSQL Getting and inserting - by JaTochNietDan - 21.02.2011, 21:01

Forum Jump:


Users browsing this thread: 2 Guest(s)