mysql problem
#1

So i was trying to do a login/register system with mysql, i'm using mysql version r33

so basically i was trying to make a stock to save player data, the code is correct but it's not updating on mysql,

here is the code of the stock

Код:
stock SavePlayerData(playerid)
{
    new Query[1000],PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    PlayerInfo[playerid][Cash] = GetPlayerMoney(playerid);
	GetPlayerPos(playerid, PlayerInfo[playerid][LastPosX], PlayerInfo[playerid][LastPosY], PlayerInfo[playerid][LastPosZ]);
    GetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
	GetPlayerArmour(playerid, PlayerInfo[playerid][Armour]);
    mysql_format(MySQL, Query, sizeof(Query), "UPDATE `players` SET `NormalName` = '%s', `Password` = '%s', `Cash` = '%d', `BankMoney` = '%d', `LastPosX` = '%f', `LastPosY` ='%f',`LastPosZ` = '%f',`Health` = '%f',`Armour` = '%f' WHERE `NormalName` = '%f' LIMIT 1",
               PlayerName,
               RetrievePassword(playerid),
               PlayerInfo[playerid][Cash],
               PlayerInfo[playerid][BankMoney],
               PlayerInfo[playerid][LastPosX],
               PlayerInfo[playerid][LastPosY],
               PlayerInfo[playerid][LastPosZ],
               PlayerInfo[playerid][Health],
               PlayerInfo[playerid][Armour],
               PlayerName);
    mysql_query(MySQL, Query);
}
In the mysql debug, there is no errors too

Код:
[02:03:48] [DEBUG] mysql_format - connection: 1, len: 1000, format: "UPDATE `players` SET `NormalName` = '%s', `Password` = '%s', `Cash` = '%d', `BankMoney` = '%d', `LastPosX` = '%f', `LastPosY` ='..."
[02:03:49] [DEBUG] mysql_query - connection: 1, query: "UPDATE `players` SET `NormalName` = 'Alexander_Cooper', `Passwor"
[02:03:49] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called
[02:03:49] [DEBUG] CMySQLQuery::Execute[()] - starting query execution
[02:03:49] [DEBUG] CMySQLQuery::Execute[()] - query was successful
[02:03:49] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[02:03:49] [DEBUG] CMySQLHandle::SaveActiveResult - cache saved with ID = 2
[02:03:49] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called
Thanks in advance.
Reply
#2

%f is a float value, not a string. Change %f to %e at the end of the mysql_format(NormalName).
Reply
#3

That still doesn't fix the problem.
Reply
#4

Place print(Query) after the mysql_query function and post what shows up in the server log.
Reply
#5

You really shouldn't save your data by the players name. Use row id/sqlid with the auto_increment value.

And by the way you are saving the password and the players name for no reason and you didn't escape the players name.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)