Mysql | Always wrong password
#1

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

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 !
Reply
#3

All you have changed is the colour ...
Reply
#4

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, ..
Reply
#5

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.
Reply
#6

Quote:
Originally Posted by thefatshizms
View Post
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.
Reply
#7

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)
Reply
#8

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..
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)