Mysql saving issues -
Abreezy - 08.08.2011
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.
Re: Mysql saving issues -
Calgon - 08.08.2011
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.
Re: Mysql saving issues -
Abreezy - 08.08.2011
Код:
[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
Re: Mysql saving issues -
Donya - 08.08.2011
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;
}
Re: Mysql saving issues -
Abreezy - 08.08.2011
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.
Re: Mysql saving issues -
Abreezy - 08.08.2011
pawn Код:
(377) : error 035: argument type mismatch (argument 2)
Error occurred on the format line.
Re: Mysql saving issues -
Donya - 08.08.2011
I just edited it, try it again.
Re: Mysql saving issues -
Abreezy - 08.08.2011
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.
Re: Mysql saving issues -
Abreezy - 08.08.2011
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]);
Re: Mysql saving issues -
Donya - 08.08.2011
its not that line, because the string's have lengths.