error 035: argument type mismatch (argument 2)
#1

Hello,

Im following this tutorial on how to use Mysql,
And im trying to make a register command,
And im getting this:

Код:
C:\Users\Torran\Desktop\tRoleplay\filterscripts\mysqltest.pwn(305) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
pawn Код:
mysql_query("INSERT INTO `users` (`username`, `password`) VALUES ('%s', MD5('%s'))",PlayerName, password);
Any ideas why?
Reply
#2

Quote:
Originally Posted by Joe Torran C
Hello,

Im following this tutorial on how to use Mysql,
And im trying to make a register command,
And im getting this:

Код:
C:\Users\Torran\Desktop\tRoleplay\filterscripts\mysqltest.pwn(305) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
pawn Код:
mysql_query("INSERT INTO `users` (`username`, `password`) VALUES ('%s', MD5('%s'))",PlayerName, password);
Any ideas why?
mysql_query only accepts 1 parameter (the query string). Use format to format the string with your variables.

EDIT: offtopic, but make sure you escape the password string (mysql_real_escape_string is the function to do so) ... other wise your server is vulnerable to sql abuse / could crash.
Reply
#3

I dont get it?
I dont have a clue how to use mysql
Got a example?
Reply
#4

Quote:
Originally Posted by Joe Torran C
I dont get it?
I dont have a clue how to use mysql
Got a example?
hmmm a quick one, i guess lol.

Код:
new String[128], String2[32];

format(String, sizeof(String), "INSERT INTO `users` (`username`, `password`) VALUES ('%s', MD5('%s'))",PlayerName, password);
mysql_real_escape_string(String,String2), mysql_query(String);
Reply
#5

Do you know any register commands for this?
As mine dosent look like its saving
Reply
#6

Quote:
Originally Posted by Joe Torran C
Do you know any register commands for this?
As mine dosent look like its saving
ummm, i do not, sorry.

Here one a made a loooong time ago (i still use it lol, it works fine ... just a bit.. eh messy)

Код:
dcmd_register(playerid, params[])
{
	if(!sscanf(params, "s[40]", pData[playerid][Password]))
	{
		if(pData[playerid][IsRegistered] == false)
		{
			new SkinID = GetPlayerSkin(playerid);
			GetPlayerIp(playerid, pData[playerid][IP], 16);
			mysql_real_escape_string(pData[playerid][Password],String);
			format(String2, sizeof(String2), "INSERT INTO `users` (Name,Password,Skin,IP) VALUES('%s', SHA1('%s'), %d, '%s')", pData[playerid][Name],pData[playerid][Password],SkinID,pData[playerid][IP]);
			mysql_query(String2);

			format(String, sizeof(String), "Registration successful! Please remember your user name (%s) and password (%s)!",pData[playerid][Name],pData[playerid][Password]);
			SendClientMessage(playerid, yellow, String);
			SendClientMessage(playerid, white, "You have been automatically logged in.");
			pData[playerid][IsRegistered] = true;
			pData[playerid][LoggedIn] = true;
			return 1;
		}
		format(String, sizeof(String), "Error: Username \"%s\" is already registered, please chose a different nick name!",pData[playerid][Name]);
		SendClientMessage(playerid, red, String);
 		return 1;
	}
	SendClientMessage(playerid, red, "Error: /register <Password>");
	return 1;
}
will need to edit it to work of course.


EDIT: if you use the sha1 encryption, make sure the password length in your db is at least 40.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)