SA-MP Forums Archive
Msyql Problem - 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)
+--- Thread: Msyql Problem (/showthread.php?tid=605757)



Msyql Problem - tobstar112 - 24.04.2016

Hello i have a very bis Problem the password is always wrong.
Код:
stock mysql_CheckPasswort(Name[],Passwort[])
{
 	new query[256];
	if(strlen(Name) < 1 || strlen(Passwort) < 1) return 0;
    mysql_escape_string(Name,Name,dbhandle,126);
    mysql_escape_string(Passwort,Passwort,dbhandle,126);
    format(query,sizeof(query),"SELECT * FROM Accounts WHERE Username='%s' AND Passwort=SHA1('%s')",Name,Passwort);
 	mysql_query(dbhandle,query,true);
	printf("%d",cache_num_rows());
	if(cache_num_rows() == 0)
	{
	    return 0;
	}
	else
	{
	    return 1;
	}
}



Re: Msyql Problem - introzen - 24.04.2016

Post the encrypted password input and the pass from the database please.


Re: Msyql Problem - tobstar112 - 24.04.2016

Here is it

Quote:

CreateAccount(playerid, RegisPass1[playerid]);

stock CreateAccount(playerid, pass[])
{
new query[256];
mysql_real_escape_string(RegisName[playerid], RegisName[playerid]);
mysql_real_escape_string(pass, pass, dbhandle, 12;
format(query, sizeof(query), "INSERT INTO `accounts` (`Username`, `Passwort`) VALUES ('%s',SHA1('%s'))", RegisName[playerid], pass);
mysql_query(dbhandle, query);
sInfo[playerid][db_id] = cache_insert_id();
return true;
}

strmid(RegisPass1[playerid], inputtext, 0, strlen(inputtext), 12;

Datenbank= 148627088915c721ccebb4c611b859031037e6ad




Re: Msyql Problem - introzen - 24.04.2016

Код:
stock mysql_CheckPasswort(Name[],Passwort[])
{
 	new query[256];
	if(strlen(Name) < 1 || strlen(Passwort) < 1) return 0;
    mysql_escape_string(Name,Name,dbhandle,128);
    mysql_escape_string(Passwort,Passwort,dbhandle,128);
    format(query,sizeof(query),"SELECT * FROM Accounts WHERE Username='%s' AND Passwort=SHA1('%s')",Name,Passwort);
 	mysql_query(dbhandle,query,true);
	printf("%d",cache_num_rows());
	if(cache_num_rows() == 0)
	{
	    return 0;
	}
	else
	{
	    return 1;
	}
}
Also, check the length of the query. SHA1 is 40 characters


Re: Msyql Problem - CodeStyle175 - 24.04.2016

mysql_format with %e will escape string


Re: Msyql Problem - tobstar112 - 24.04.2016

What ca i Do ?


Re: Msyql Problem - tobstar112 - 24.04.2016

Can other Help me ?