Problem loading accounts via MySQL
#1

Код:
stock LoadAccount(playerid)
{
	new Escape[2][MAX_PLAYER_NAME];

	mysql_real_escape_string(PlayerInfo[playerid][pName], Escape[0]);
	mysql_real_escape_string(mysql_account_table, Escape[1]);

	format(query, sizeof(query), "SELECT * FROM `%s` WHERE `username` = '%s'", Escape[1], Escape[0]);
	mysql_query(query);
	mysql_store_result();

	if(mysql_num_rows())
	{
		if(mysql_fetch_row(largestr))
		{
            if(!sscanf(largestr, mysql_user_string, PlayerInfo[playerid]))
			{
        		PlayerInfo[playerid][pLoggedIn] = 1;
        		PlayerInfo[playerid][pRegistered] = 1;
        		PlayerInfo[playerid][pIsNew] = 0;
                printf("[DEBUG]: Player %s(%d) Stats loaded!", PlayerInfo[playerid][pName], playerid);
				return 1;
			}
			format(str, sizeof(str), "Player %s(%d) - SSCANF loading error", PlayerInfo[playerid][pName], playerid);
			Error("MYSQL", str);
			AccountError(playerid);
			mysql_free_result();
			return 1;
		}
		format(str, sizeof(str), "Player %s(%d) - Cannot fetch player row", PlayerInfo[playerid][pName], playerid);
		Error("MYSQL", str);
		AccountError(playerid);
		mysql_free_result();
		return 1;
	}
	format(str, sizeof(str), "Player %s(%d) - Cannot find player in the mysql database", PlayerInfo[playerid][pName], playerid);
    Error("MYSQL", str);
    AccountError(playerid);
	mysql_free_result();
	return 1;
}
When I login and create a new account, it all saves to the database. When I log back in the server closes the connection with this error

Код:
		format(str, sizeof(str), "Player %s(%d) - SSCANF loading error", PlayerInfo[playerid][pName], playerid);
I'm obviously using a base MySQL script and do not understand what the issue at hand is, can someone please point me in the right direction here.
Reply
#2

Why you use sscanf on a login system?
sscanf is used for splitting strings into other strings / cells (or int)/Floats etc. ( sscanf means: StringSCANFormat, also known as unformat )
Reply
#3

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
Why you use sscanf on a login system?
sscanf is used for splitting strings into other strings / cells (or int)/Floats etc. ( sscanf means: StringSCANFormat, also known as unformat )
It's what the base came as, can't find any other working MySQL base rn so
Reply
#4

Base are for new scripters. True scripters script it themselves... Also as a login system I used something like:
  • Check if the user exists in the database
  • Get his password from DataBase
  • Compare it with the password he introduced in the dialog
  • If they match the player is logged in, else no
Reply
#5

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
Base are for new scripters. True scripters script it themselves... Also as a login system I used something like:
  • Check if the user exists in the database
  • Get his password from DataBase
  • Compare it with the password he introduced in the dialog
  • If they match the player is logged in, else no
I learn through starting with a base and developing onwards, I will try do it from scratch anyway but..
Reply
#6

check mysql logs
Reply
#7

A basic script is fine ... as long as you don't pick something that is ancient. When was that script released? 2010 maybe?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)