Saving ip
#1

I have a problem saving the IP of the player who registers an account.

This is the register query:

pawn Код:
case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
           
            if(CheckDialogBug(inputtext)) return SendClientMessage(playerid, 0, "{FFFFFF}You can't use '%' in strings.");

            if (strlen(inputtext) <= 5) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", "Your password must be longer than 5 characters!\nPlease enter your password in the field below:", "Register", "Abort");

            // 16 random characters from 33 to 126 (in ASCII) for the salt
            for (new i = 0; i < 16; i++) Player[playerid][Salt][i] = random(94) + 33;
            SHA256_PassHash(inputtext, Player[playerid][Salt], Player[playerid][Password], 65);

            new query[221];
            mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `IP`) VALUES ('%e', '%s', '%e', '%s')",
            Player[playerid][Name],
            Player[playerid][Password],
            Player[playerid][Salt]),
            ReturnPlayerIp(playerid);
            mysql_tquery(g_SQL, query, "OnPlayerRegister", "d", playerid);
        }
This is the log:

Quote:

[22:06:04] [ERROR] mysql_format: no value for specifier '%s' passed
[22:06:04] [ERROR] error #1065 while executing query "": Query was empty

ReturnPlayerIp func:

Код:
ReturnPlayerIp(playerid)
{
	new ip[24];
	GetPlayerIp(playerid, ip, 24);
	return ip;
}
Reply
#2

Blind? /s

Quote:

mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `IP`) VALUES ('%e', '%s', '%e', '%s')",
Player[playerid][Name],
Player[playerid][Password],
Player[playerid][Salt]),
ReturnPlayerIp(playerid);

You closed the bracket too early

Код:
mysql_format(g_SQL, query, sizeof query, "INSERT INTO `players` (`username`, `password`, `salt`, `IP`) VALUES ('%e', '%s', '%e', '%s')",
			Player[playerid][Name],
			Player[playerid][Password],
			Player[playerid][Salt],
			ReturnPlayerIp(playerid));
Reply
#3

Omg why.

Thank you pig.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)