Player data loading but not saving
#1

Can anybody figure out whats wrong here, when I join my server and /register it doesn't save to MySQL database, its connected properly because if I manually create a new account by adding it to the MySQL database it successfully loads in-game its just not saving for some reason


MySQLCreateAccount stock:
Код:
stock MySQLCreateAccount(newplayersname[], newpassword[]) 
{
	new query[128];
	new sqlplyname[64];
	new sqlpassword[64];
	mysql_real_escape_string(newplayersname, sqlplyname);
	mysql_real_escape_string(newpassword, sqlpassword);
	format(query, sizeof(query), "INSERT INTO playerinfo (user, password) VALUES ('%s', '%s')", sqlplyname, sqlpassword);
	mysql_query(query);
	new newplayersid = MySQLCheckAccount(newplayersname);
	if (newplayersid != 0)
	{
		return newplayersid;
	}
	return 0;
}
OnDialogResponse for /register dialog:
Код:
mysql_real_escape_string(inputtext, escpass);

				//mysql_real_escape_string(PlayerInfo[playerid][pName],PlayerInfo[playerid][pName]);
				//mysql_real_escape_string(inputtext,inputtext);

				format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES('%s', SHA1('%s'), '%s')", PlayerInfo[playerid][pName], escpass, PIP);
				mysql_query(query);

            	//format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES ('%s', md5('%s'), '%s')",PlayerInfo[playerid][pName], inputtext, PIP); //Insert string
				//mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET Registered = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]);
				mysql_query(query); //queries

				format(query,sizeof(query),"UPDATE playerdata SET LastLogin = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]);
				mysql_query(query); //queries

				mysql_free_result();

                PlayerInfo[playerid][pLogged] = 1;
                PlayerInfo[playerid][pRegistered] = 1;
                //SendClientMessage(playerid, COLOR_SERVER_MAIN_MSG, "Registered And Logged In.");
empty sql table after /registering in-game:
Reply
#2

What version of the plugin are you using?

R40+
pawn Код:
mysql_log(ALL);
//Creates folder/files in /logs/
R39(ish)
pawn Код:
mysql_log(LOG_ALL, LOG_TYPE_HTML); //Or log_type_text. HTML is easier on the eyes.
Stop using MD5 also. Its no longer secure. Please read this for more info.
Reply
#3

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
What version of the plugin are you using?

R40+
pawn Код:
mysql_log(ALL);
//Creates folder/files in /logs/
R39(ish)
pawn Код:
mysql_log(LOG_ALL, LOG_TYPE_HTML); //Or log_type_text. HTML is easier on the eyes.
Stop using MD5 also. Its no longer secure. Please read this for more info.
I'm using R5
Код:
	SA-MP MySQL plugin R5
	Copyright © 2008-2010, G-sTyLeZzZ
the gamemode is pretty old and wont work with more up to date versions of MySQL but it should still be able to save to the sql tables shouldn't it?
Reply
#4

Quote:

Whatever your gamemode is you should always update the version of every include or plugin you are using

I can't remember who said that but you've got a long way of converting since most of the functions in the r5 are deprecated and since MySQL also updates which means how the database functions also changes

To be 100% sure that it will work updating is a must..

and by the way there's no such things as gamemodes that can't be updated everything can and will always will be all you have to do is learn the new thing...
Reply
#5

Pretty sure R5 will still hand out the data... It's not as if it simply stopped being.
Reply
#6

Quote:
Originally Posted by Ducati
Посмотреть сообщение
Can anybody figure out whats wrong here, when I join my server and /register it doesn't save to MySQL database, its connected properly because if I manually create a new account by adding it to the MySQL database it successfully loads in-game its just not saving for some reason


MySQLCreateAccount stock:
Код:
stock MySQLCreateAccount(newplayersname[], newpassword[]) 
{
	new query[128];
	new sqlplyname[64];
	new sqlpassword[64];
	mysql_real_escape_string(newplayersname, sqlplyname);
	mysql_real_escape_string(newpassword, sqlpassword);
	format(query, sizeof(query), "INSERT INTO playerinfo (user, password) VALUES ('%s', '%s')", sqlplyname, sqlpassword);
	mysql_query(query);
	new newplayersid = MySQLCheckAccount(newplayersname);
	if (newplayersid != 0)
	{
		return newplayersid;
	}
	return 0;
}
OnDialogResponse for /register dialog:
Код:
mysql_real_escape_string(inputtext, escpass);

				//mysql_real_escape_string(PlayerInfo[playerid][pName],PlayerInfo[playerid][pName]);
				//mysql_real_escape_string(inputtext,inputtext);

				format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES('%s', SHA1('%s'), '%s')", PlayerInfo[playerid][pName], escpass, PIP);
				mysql_query(query);

            	//format(query, sizeof(query), "INSERT INTO playerdata (UserName, Password, IP) VALUES ('%s', md5('%s'), '%s')",PlayerInfo[playerid][pName], inputtext, PIP); //Insert string
				//mysql_query(query);

				format(query,sizeof(query),"UPDATE playerdata SET Registered = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]);
				mysql_query(query); //queries

				format(query,sizeof(query),"UPDATE playerdata SET LastLogin = '%s' WHERE (UserName = '%s')",LastLogin,PlayerInfo[playerid][pName]);
				mysql_query(query); //queries

				mysql_free_result();

                PlayerInfo[playerid][pLogged] = 1;
                PlayerInfo[playerid][pRegistered] = 1;
                //SendClientMessage(playerid, COLOR_SERVER_MAIN_MSG, "Registered And Logged In.");
empty sql table after /registering in-game:
Use ` key that is below the escape key instead of single quote key in your query.

for eg:
Код:
 SELECT * from users where name = `%s`
Same happened with me when I started working on MySQL. Dont know why didnt single quote worked. I learned from wiki and I thought its a single quote. but it didnt work so I copied Wiki's code and ran it, it worked, thats how I got it that its not single quote, but its ` key.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)