Msyql Problem
#1

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;
	}
}
Reply
#2

Post the encrypted password input and the pass from the database please.
Reply
#3

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

Reply
#4

Код:
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
Reply
#5

mysql_format with %e will escape string
Reply
#6

What ca i Do ?
Reply
#7

Can other Help me ?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)