playerdata not writing into table
#1

Resolved

When my player registers everything works fine, it just doesnt insert the information into the playerdata table.
Please help.

Here is my code:
Код:
case DIALOG_REGISTER:
	    {
	        if(response)
	        {
			    if(strlen(inputtext) == 0)
			    {
			        new IP[16], str[128], string[168];
			        GetPlayerIp(playerid, IP, 16);
			        format(string, sizeof(string), "Welcome to Legion of Los Angeles, %s \n\n IP Address: %i \n\n You may register an account by entering a desired password here:", GetName(playerid), IP);
		            ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, str, string, "Register", "Cancel");
				}
				else
				{
				    new EscapedText[60], Query[168];
				    mysql_real_escape_string(inputtext, EscapedText);
				    format(Query, sizeof(Query), "INSERT INTO `playerdata` (Name,Password,Cash) VALUES ('%s','%s,'0')", GetName(playerid), EscapedText);
				    mysql_query(Query);
				    SendClientMessage(playerid, -1, "You have successfully registered.");
				    GivePlayerMoney(playerid, 5000);
				    SetPlayerScore(playerid, 1);
				}
			}
		}
Reply
#2

You forgot a ' after the second %s

Also, don't use unnecessary characters

pawn Код:
"INSERT INTO `playerdata` (Name,Password,Cash) VALUES ('%s','%s,'0')" // Old
"INSERT INTO playerdata (Name,Password,Cash) VALUES ('%s','%s',0)" // New
Reply
#3

Ok thanks
Reply
#4

As a tip I recommend hashing the passwords, having them as raw text decoded is an incredibly high security risk, both for the players (they don't usually want the server owner to know their passwords) and for the owner (if you were somehow injected or hacked... well, then they would have access to every password).

There are lots of hashing plugins in the plugins sections, and if you don't want to use anything additional SQL queries provide an in built hashing for MD5, just use MD5('%s') and it will hash automatically into MD5 (not the most secure but it's alright) anything inside of the parameters.
Reply
#5

Yeah will do that to.
One more thing.
I can register the first person perfectly, but then the next player that registers, it doesn't create a new row for them, so they have to keep registering
Reply
#6

Resolved
Reply


Forum Jump:


Users browsing this thread: