Mysql row not created
#1

The problem is when a player registers, a unique row is not created. Only 1 player row is created in the db, after that a next player registers, row is not created ...

this is my code !
Код:
MySQLregister(playerid, params[])
{
	new password[130];
	mysql_escape_string(params,password);
	new str[128];
	
    mysql_format(mysql,str,sizeof(str),"INSERT INTO `users` (`Name`, `Pass`) VALUES ('%s', '%s')",PlayerName(playerid),password);
	mysql_function_query(mysql,str,false,"","");
 FieldID[playerid] = cache_insert_id(mysql); 
	//--------------------------------------------------
	SendLangMessage(playerid, _COLOR_YELLOW, "Account wurde erstellt:","Account was created:","Tu cuenta ha sido creada:");
	switch(Sprache[playerid])
	{
		case 0: format(str, sizeof(str), "Passwort: \"%s\"",password);
		case 1: format(str, sizeof(str), "Password: \"%s\"",password);
		case 2: format(str, sizeof(str), "Contrasena: \"%s\"",password);
	}
	SendClientMessage(playerid, _COLOR_GREEN, str);
	SendLangMessage(playerid, _COLOR_GREEN, "Du wurdest eingeloggt!","You are logged in!","Has iniciado sesi鏮!");
	GivePlayerCash(playerid,10000);
	GiveClanCash(playerid,10000);
	LoggedIn[playerid] = 1;
	mysql_format(mysql,str, sizeof(str), "SELECT * FROM `users` WHERE Name = '%s'",PlayerName(playerid));
	mysql_function_query(mysql,str,true,"","");
    return 1;
}
Reply
#2

You have size of 130 for storing the password and the query itself is only 128? Increase its length so it will be enough.

Also cache_insert_id will fail. It must be in a public function (always advised to use cache, even in INSERT/UPDATE):
pawn Код:
mysql_function_query(mysql,str,true,"OnPlayerRegisterAccount","i", playerid);

// somewhere outside of any other function/callback:
forward OnPlayerRegisterAccount(playerid);
public OnPlayerRegisterAccount(playerid)
{
    FieldID[playerid] = cache_insert_id(mysql);
    return 1;
}
and what's the point in executing a query directly after that and selecting all the data? I mean, the player just registered so obviously you know all the rest of the data.
Reply
#3

sorry that didn't work
Reply
#4

-bump- found out that no error in my script, error only in mysql, only 1 row is inserted in the users table, after that a new row is not inserted(I suppose, some setting is changed in mysql, table) now how to change that setting ??
Reply
#5

I don't know what the server is doing after a select, but this might cause your next user to do nothing:

Код:
mysql_format(mysql,str, sizeof(str), "SELECT * FROM `users` WHERE Name = '%s'",PlayerName(playerid));
	mysql_function_query(mysql,str,true,"","");
The result of a select is never used so it is possible that a lock is still on the table.
Reply
#6

there is only one row created in mysql, if one row is created, the new row is not created, there is problem in mysql only, not in script, I need help regarding mysql,(I think the table only allows one row to ne inserted, I need to change that,.but I don't know that )....
Reply
#7

MySQL doesn't have a problem like that. It is your script. If a table is being altered or selected from, MySQL locks the table so that other rows can't be changed for that time being. It can very well be that that lock is still there because of an open select statement.
Reply
#8

problem solved, I had the rows in unique key, so It said an error, duplicate entry. I had to remove the unique key
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)