Minor SQL issue
#1

I am trying to make a save account system which takes the variable 'playerid' and I call it in public OnPlayerDisconnect(playerid)

pawn Код:
SaveAccount(playerid)
{
    if(IsPlayerLogged(playerid))
    {
        new query[500];
        new Float:x, Float:y, Float:z;
        format(query,sizeof(query),"UPDATE `USERS` SET SCORE = '%d', CASH = '%d', ADMINLEVEL = '%d', POSITION X = '%f', POSITION Y = '%f', POSITION Z = '%f' WHERE `NAME = '%s'",
                                                        GetPlayerScore(playerid),
                                                        GetPlayerMoney(playerid),
                                                        pInfo[playerid][AdminLevel],
                                                        x,y,z,
                                                        pName(playerid));
        return 1;
    }
    return 0;
}
I don't get any errors but neither does it update in the table. Any kind of helpful reply will be appreciated.
Reply
#2

I've got feelings it isn't saving is because you've maybe put Users in caps, as far as I am concerned, your UPDATE stuff is correctly formated.

Try re-seeing names.
Reply
#3

Try one of the following, it might be a problem of `'s

pawn Код:
SaveAccount(playerid)
{
    if(IsPlayerLogged(playerid))
    {
        new query[500];
        new Float:x, Float:y, Float:z;
        format(query,sizeof(query),"UPDATE `USERS` SET `SCORE` = '%d', `CASH` = '%d', `ADMINLEVEL` = '%d', `POSITION X` = '%f', `POSITION` Y = '%f', `POSITION Z` = '%f' WHERE `NAME` = '%s'",
                                                        GetPlayerScore(playerid),
                                                        GetPlayerMoney(playerid),
                                                        pInfo[playerid][AdminLevel],
                                                        x,y,z,
                                                        pName(playerid));
        return 1;
    }
    return 0;
}
In the 2nd one I only added a ` in the end of your NAME cell.
pawn Код:
SaveAccount(playerid)
{
    if(IsPlayerLogged(playerid))
    {
        new query[500];
        new Float:x, Float:y, Float:z;
        format(query,sizeof(query),"UPDATE `USERS` SET SCORE = '%d', CASH = '%d', ADMINLEVEL = '%d', POSITION X = '%f', POSITION Y = '%f', POSITION Z = '%f' WHERE `NAME` = '%s'",
                                                        GetPlayerScore(playerid),
                                                        GetPlayerMoney(playerid),
                                                        pInfo[playerid][AdminLevel],
                                                        x,y,z,
                                                        pName(playerid));
        return 1;
    }
    return 0;
}
Reply
#4

Are you even executing the query?
Reply
#5

This may be the main problem.
Quote:
Originally Posted by Misiur
Посмотреть сообщение
Are you even executing the query?
And something more: When using %d (integer) remove the apostrophes, use them only in string ('%s')
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)