Mysql | Always wrong password -
thefatshizms - 23.01.2013
Hello, when i enter the
correct password it always says that it's incorrect.. I have no idea where I have gone wrong and been trying different things to fix it but.. no luck
pawn Code:
public Mysql_Login(playerid, password[])
{
mysql_real_escape_string(PlayerName(playerid), PlayerName(playerid));
mysql_real_escape_string(password, password);
new Hash[129], Query[500];
WP_Hash(Hash, 129, password);
format(Query, 500, "SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'", PlayerName(playerid), Hash);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You have been logged in and your {FF0000}stats are loaded");
LoggedIn[playerid] = 1;
}
else
{
SendClientMessage(playerid, -1, "Wrong password");
}
mysql_free_result();
return 1;
}
Re: Mysql | Always wrong password -
Sweez - 23.01.2013
Code:
public Mysql_Login(playerid, password[])
{
mysql_real_escape_string(PlayerName(playerid), PlayerName(playerid));
mysql_real_escape_string(password, password);
new Hash[129], Query[500];
WP_Hash(Hash, 129, password);
format(Query, 500, "SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'", PlayerName(playerid), Hash);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You have been logged in and your {FF0000}stats are loaded");
LoggedIn[playerid] = 1;
}
else
{
SendClientMessage(playerid, 0, "Wrong password");
}
mysql_free_result();
return 1;
}
Try this, if it doesnt work i cant help you, sorry !
Re: Mysql | Always wrong password -
thefatshizms - 23.01.2013
All you have changed is the colour ...
Re: Mysql | Always wrong password -
FUNExtreme - 23.01.2013
First: have you tried running the query in phpmyadmin to see if it is correct and what it returns?
Second: have you tried printing everything, the hashed password, the received information, ..
Re: Mysql | Always wrong password -
thefatshizms - 23.01.2013
Yes i've tried the printing. Also, within the mysql debug it says that the result returns 0 results though, when i look in the phpmyadmin my name and pass etc is there.
Re: Mysql | Always wrong password -
FUNExtreme - 23.01.2013
Quote:
Originally Posted by thefatshizms
the mysql debug it says that the result returns 0 results
|
Do more debugging until you find out why it returns 0. It would return at least one row if your query was correct.
Re: Mysql | Always wrong password -
thefatshizms - 23.01.2013
Ok, i have looked into it and i can see that it's all doing fine, hashing etc i look into the phpmyadmin and not all the hash is in there, like 1/4 is missing so... how do i fix this?
(note: in debug in the query its displaying its inserting the WHOLE hash but while it was querying it must of been shortened or somethin)
Re: Mysql | Always wrong password -
DanLore - 23.01.2013
In your MySQL database, check the size of the password field, if some is cut off then this could be the issue. You should determine the max size of the hashed password, and then adjust the table structure accordingly..
Re: Mysql | Always wrong password -
thefatshizms - 23.01.2013
Ah yes, i forgot about that. The length at this moment is 100 which explains why the full length of the hash wasn't getting in. Thanks