SA-MP Forums Archive
error 035: argument type mismatch (argument 2) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error 035: argument type mismatch (argument 2) (/showthread.php?tid=132956)



error 035: argument type mismatch (argument 2) - Torran - 10.03.2010

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?


Re: error 035: argument type mismatch (argument 2) - Kyosaur - 10.03.2010

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.


Re: error 035: argument type mismatch (argument 2) - Torran - 10.03.2010

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


Re: error 035: argument type mismatch (argument 2) - Kyosaur - 10.03.2010

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);



Re: error 035: argument type mismatch (argument 2) - Torran - 10.03.2010

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


Re: error 035: argument type mismatch (argument 2) - Kyosaur - 10.03.2010

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.