MySQL not saving
#1

Код:
stock SavePlayerAccount(playerid)
{
	new DB_Query[1024];
	
	new
		   	Float:x,
		    Float:y,
			Float:z
		;
		
		
	if(PlayerInfo[playerid][LoggedIn] == 1)
	{
	    GetPlayerPos(playerid,x,y,z);
		PlayerInfo[playerid][pPos_x] = x;
		PlayerInfo[playerid][pPos_y] = y;
		PlayerInfo[playerid][pPos_z] = z;
	
	    mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `PASSWORD` = '%s', `SCORE` = '%d', `KILLS` = '%d', `CASH` = '%d', `DEATHS` = '%d', `Admin` = '%d'"
		, PlayerInfo[playerid][pPass], PlayerInfo[playerid][Score], PlayerInfo[playerid][Kills], PlayerInfo[playerid][pCash], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][pAdmin]);
		mysql_tquery(Database, DB_Query);
		
		mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `Sex` = '%d', `Age` = '%d', `Pos_x` = '%f', `Pos_y` = '%f', `Pos_z` = '%f', `Skin` = '%d', `Job` = '%d', `AccLock` = '%d'"
		, PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pAccLock]);
	    mysql_tquery(Database, DB_Query);
	}

	return 1;
}
and when the player disconnect:
Код:
SavePlayerAccount(playerid);
It doesn't work.


Also this is not working:
Код:
case DIALOG_EMAIL:
		{
		    if(response)
		    {
		        new DB_Query[225];
		        new iemail = strval(inputtext);
		        PlayerInfo[playerid][pEmail] = iemail;
				mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `email` = '%s'"
				, PlayerInfo[playerid][pEmail]);
				mysql_tquery(Database, DB_Query);
				
				SendClientMessage(playerid, COLOR_GREEN, "Email set succesfully! Moving onto the next part, gender!");
				
				ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "{FFA500}GENDER", "{FFFFFF}Are you a boy or a girl?\n\n", "BOY", "GIRL");
			}
		}
The email is not saving



I solved with others but the email is not saving, any idea why?
Reply
#2

Please find a reputable site to learn SQL. You don't have a WHERE-clause in any of your queries.
Reply
#3

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
Код:
stock SavePlayerAccount(playerid)
{
	new DB_Query[1024];
	
	new
		   	Float:x,
		    Float:y,
			Float:z
		;
		
		
	if(PlayerInfo[playerid][LoggedIn] == 1)
	{
	    GetPlayerPos(playerid,x,y,z);
		PlayerInfo[playerid][pPos_x] = x;
		PlayerInfo[playerid][pPos_y] = y;
		PlayerInfo[playerid][pPos_z] = z;
	
	    mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `PASSWORD` = '%s', `SCORE` = '%d', `KILLS` = '%d', `CASH` = '%d', `DEATHS` = '%d', `Admin` = '%d'"
		, PlayerInfo[playerid][pPass], PlayerInfo[playerid][Score], PlayerInfo[playerid][Kills], PlayerInfo[playerid][pCash], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][pAdmin]);
		mysql_tquery(Database, DB_Query);
		
		mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `Sex` = '%d', `Age` = '%d', `Pos_x` = '%f', `Pos_y` = '%f', `Pos_z` = '%f', `Skin` = '%d', `Job` = '%d', `AccLock` = '%d'"
		, PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pAccLock]);
	    mysql_tquery(Database, DB_Query);
	}

	return 1;
}
Is there any error message on your mysql log? Also, you need to add WHERE clause on your queries above to make it only update a single player stats. Otherwise, every data inside USERS table will be updated too.

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
Also this is not working:
Код:
case DIALOG_EMAIL:
		{
		    if(response)
		    {
		        new DB_Query[225];
		        new iemail = strval(inputtext);
		        PlayerInfo[playerid][pEmail] = iemail;
				mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `USERS` SET `email` = '%s'"
				, PlayerInfo[playerid][pEmail]);
				mysql_tquery(Database, DB_Query);
				
				SendClientMessage(playerid, COLOR_GREEN, "Email set succesfully! Moving onto the next part, gender!");
				
				ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_MSGBOX, "{FFA500}GENDER", "{FFFFFF}Are you a boy or a girl?\n\n", "BOY", "GIRL");
			}
		}
The email is not saving
Why are you converting an email to integer?
Код:
new iemail = strval(inputtext);
And, you need to use '%e' to escape string instead of '%s' in query above as it's injectable. And same as above, you need to add WHERE clause in that query.
Reply
#4

Quote:
Originally Posted by X337
Посмотреть сообщение
Is there any error message on your mysql log? Also, you need to add WHERE clause on your queries above to make it only update a single player stats. Otherwise, every data inside USERS table will be updated too.



Why are you converting an email to integer?
Код:
new iemail = strval(inputtext);
And, you need to use '%e' to escape string instead of '%s' in query above as it's injectable. And same as above, you need to add WHERE clause in that query.
I fixed the WHERE and injection after I posted this, still I don't know how to save that email, if I use iemail[36] = inputtext I will get a error..
Reply
#5

Did you just ignored Vince? Who just told you exactly what to do to fix your problem? SERIOUSLY?
Reply
#6

You need to format them, you can use format() or strcat().
Код:
format(PlayerInfo[playerid][pEmail], 128, "%s", inputtext);
Reply
#7

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
Did you just ignored Vince? Who just told you exactly what to do to fix your problem? SERIOUSLY?
He said that I was missing WHERE, and I said that I added it after I posted this topic.
Reply
#8

Then Post the edited Code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)