Not registering the players accounts [MYSQL]
#1

Код:
	switch(dialogid)
	{
	    case dlogin: //login dialog
	    {
	        if(!response) Kick(playerid); //if they clicked Quit, we will kick them
	        new hpass[129]; //for password hashing
            new query[100]; // for formatting our query.
	        WP_Hash(hpass, 129, inputtext); //hashing inputtext
	        if(!strcmp(hpass, PlayerInfo[playerid][Password])) //remember we have loaded player's password into this variable, pInfo[playerid][Password] earlier. Now let's use it to compare the hashed password with password that we load
	        { //if the hashed password matches with the loaded password from database
	            mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
				//let's format our query
				//We select all rows in the table that has your name and limit the result to 1
				mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
				//lets execute the formatted query and when the execution is done, a callback OnAccountLoad will be called
				//You can name the callback however you like
			}
			else //if the hashed password didn't match with the loaded password(pInfo[playerid][Password])
			{
			    //we tell them that they have inserted a wrong password
				ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login\nWrong password!", "Login", "Quit");
			}
		}
		case dregister: //register dialog
		{
		    if(!response) return Kick(playerid); //if they clicked Quit, we will kick them
		    if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Test - Login", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
			//strlen checks a lenght of a string. so if player types their password that is lower than 6, we tell them; Your password must be at least 6 characters long!
            new query[300];
			WP_Hash(PlayerInfo[playerid][Password], 129, inputtext); //hashing inputtext
			mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0)", Name[playerid], PlayerInfo[playerid][Password], IP[playerid]);
			//Now let's create a new row and insert player's information in it
			mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
			//let's execute the query
		}
	}
Код:
forward OnAccountRegister(playerid);
public OnAccountRegister(playerid)
{
    PlayerInfo[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
    printf("New account registered. ID: %d", PlayerInfo[playerid][ID]); //just for debugging.
    return 1;
}


Код:
[08:11:13] [DEBUG] mysql_format - connection: 1, len: 128, format: "SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1"
[08:11:13] [DEBUG] mysql_tquery - connection: 1, query: "SELECT `Password`, `ID` FROM `players` WHERE `Username` = 'Test'", callback: "OnAccountCheck", format: "i"
[08:11:13] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - starting query execution
[08:11:13] [DEBUG] cache_get_data - connection: 1
[08:11:13] [WARNING] cache_get_data - no active cache
[08:11:13] [DEBUG] CMySQLQuery::Execute[OnAccountCheck] - query was successfully executed within 68.744 milliseconds
[08:11:13] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[08:11:13] [DEBUG] Calling callback "OnAccountCheck"..
[08:11:13] [DEBUG] cache_get_data - connection: 1
[08:11:13] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[08:11:18] [DEBUG] mysql_format - connection: 1, len: 300, format: "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`) VALUES ('%e', '%s', '%s', ..."
[08:11:18] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `V", callback: "OnAccountRegister", format: "i"
[08:11:18] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - starting query execution
[08:11:18] [ERROR] CMySQLQuery::Execute[OnAccountRegister] - (error #1054) Unknown column 'PosX' in 'field list'
[08:11:18] [DEBUG] CMySQLQuery::Execute[OnAccountRegister] - error will be triggered in OnQueryError
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)