Mysql saving issues
#1

Hey, I can't figure out what is the problem with this saving function, if someone could fix it up and explain whats wrong or so, I would appreciate it. I spent hours tweaking it but no change.

pawn Код:
stock SavepInfo(playerid)
{
    if(GetPVarInt(playerid, "Logged") == 1)
    {
        mysql_format(Handler, szQuery, "UPDATE playerinfo SET user = '%s', pass = '%e', Adminlvl = %d, Level = %d, Money = %d, ppos_x = %f, ppos_y = %f, ppos_z = %f, Skin = %d, Gender = %d WHERE user = '%s'",

        pName(playerid),
        pInfo[playerid][pass],
        pInfo[playerid][Adminlvl],
        pInfo[playerid][Level],
        GetPlayerMoney(playerid),
        pInfo[playerid][ppos_x],
        pInfo[playerid][ppos_y],
        pInfo[playerid][ppos_z],
        pInfo[playerid][Skin],
        pInfo[playerid][Gender],
        pName(playerid)

        );

        mysql_query(szQuery);
        mysql_free_result();
        return 1;
    }
    else return 0;
}
Only username and password saves, nothing else.
Reply
#2

Try print szQuery to see what the query prints out before it's executed.

Also what result are you freeing? When you send an update query, no result is stored.
Reply
#3

Код:
[17:56:49] CMySQLHandler::FetchRow() - Return: Tyrone_Williams|31311|0|0|0||||0|0

[17:56:49] >> mysql_free_result( Connection handle: 1 )

[17:56:49] CMySQLHandler::FreeResult() - Result was successfully free'd.
It says that in my debug file
Reply
#4

why do you update the username for the exact same user? not worth doing.

pawn Код:
stock SavepInfo(playerid)
{
    if(GetPVarInt(playerid, "Logged") != 1) return 0;
    mysql_format(Handler, szQuery, "UPDATE playerinfo SET pass = '%e', Adminlvl = %d, Level = %d, Money = %d, ppos_x = %f, ppos_y = %f, ppos_z = %f, Skin = %d, Gender = %d WHERE user = '%e'",

    pInfo[playerid][pass],
    pInfo[playerid][Adminlvl],
    pInfo[playerid][Level],
    GetPlayerMoney(playerid),
    pInfo[playerid][ppos_x],
    pInfo[playerid][ppos_y],
    pInfo[playerid][ppos_z],
    pInfo[playerid][Skin],
    pInfo[playerid][Gender],
    pName(playerid)

    );
   
    printf("Saving pInfo: %s", szQuery);
    mysql_query(szQuery);
    return 1;
}
check the server log.

if something still goes wrong, it might be mysql_format (I've heard bugs about it), try normal format

pawn Код:
stock SavepInfo(playerid)
{
    if(GetPVarInt(playerid, "Logged") != 1) return 0;
    new Escape[2][MAX_PLAYER_NAME];
    mysql_real_escape_string(pName(playerid), Escape[0]);
    mysql_real_escape_string(pInfo[playerid][pass], Escape[1]);
    format(szQuery, 256, "UPDATE playerinfo SET pass = '%s', Adminlvl = %d, Level = %d, Money = %d, ppos_x = %f, ppos_y = %f, ppos_z = %f, Skin = %d, Gender = %d WHERE user = '%s'",

    Escape[1],
    pInfo[playerid][Adminlvl],
    pInfo[playerid][Level],
    GetPlayerMoney(playerid),
    pInfo[playerid][ppos_x],
    pInfo[playerid][ppos_y],
    pInfo[playerid][ppos_z],
    pInfo[playerid][Skin],
    pInfo[playerid][Gender],
    Escape[0]

    );

    printf("Saving pInfo: %s", szQuery);
    mysql_query(szQuery);
    return 1;
}
Reply
#5

Oh, well i'm still learning mysql, so I always thought you must save each feature or else it would get fucked up and such, and alright, I haven't heard there was problems with mysql_format, i'll try the regular way.
Reply
#6

pawn Код:
(377) : error 035: argument type mismatch (argument 2)
Error occurred on the format line.
Reply
#7

I just edited it, try it again.
Reply
#8

I'm confused a bit, why doesnt the print show up on my server logs nor my debug? I can't see if there are errors or not, but it's not really working still :/ I spent all day trying to get saving to work.
Reply
#9

Still doesn't work, i discovered a warning though:

pawn Код:
sscanf warning: Strings without a length are deprecated, please add a destination size.
I believe its on this line
pawn Код:
sscanf(szQuery, "e<p<|>s[24]s[34]ddfffdd>", pInfo[iPlayer]);
Reply
#10

its not that line, because the string's have lengths.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)