OnDialogResponse help
#1

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
	    case DIALOG_REGISTER:
	    {
			if(!response)return Kick(playerid);
			if(strlen(inputtext) < 3 || strlen(inputtext) > 30){
				ShowRegisterDialog(playerid, "Password length must be above 3 characters AND below 30 characters long.");
				return true;
	        }
        	new query[128];
	        mysql_format(sqlConnection, query, sizeof(query), "INSERT INTO players (Name, Password, RegIP) VALUES('%e', sha1('%e%'), '%e')", GetName(playerid), inputtext, GetIP(playerid));
	        mysql_pquery(sqlConnection, query, "SQL_OnAccountRegister", "i", playerid);
	    }
	    case DIALOG_LOGIN:
	    {
	        if(!response)return Kick(playerid);
	        
	        if(strlen(inputtext) < 3 || strlen(inputtext) > 30) {
				ShowLoginDialog(playerid, "Password length must be above 3 characters AND below 30 characters long.");
				return true;
			}
			
			new query[128];
			mysql_format(sqlConnection, query, sizeof(query), "SELECT id FROM players WHERE Name = '%e' AND Password = sha1('%e') LIMIT 1", GetName(playerid), inputtext);
			mysql_pquery(sqlConnection, query, "SQL_OnAccountLogin", "i", playerid);
	    }
	}
	return false;
}
so this is my ondialogresponse code, when I connect to the server and type my password and click register, the box closes and then leaves me to click spawn which throws me to blueberry. The thing is, after clicking register this is meant to happen

Код:
Server:SQL_OnAccountRegister(playerid)
{
	SendClientMessage(playerid, COLOR_WHITE, "You have successfully registered onto the server.");
	DefaultPlayerValues(playerid);
	PlayerData[playerid][pSQLID] = cache_insert_id();
}
i do not get that message, nor does anything insert into the MySQL table - please help.
Reply
#2

As always, check the logs. You also have a mistake here:
Код:
sha1('%e%')
There is an extra percent symbol which probably messes things up. If it was your intention to insert a percent symbol then it must be escaped with another percent symbol (so %% would insert a literal %).
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
As always, check the logs. You also have a mistake here:
Код:
sha1('%e%')
There is an extra percent symbol which probably messes things up. If it was your intention to insert a percent symbol then it must be escaped with another percent symbol (so %% would insert a literal %).
I'm new to MySQL, I don't mean to sound dumb but where are these things logged?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)