SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 23/01/2013, 05:52 PM   #1
thefatshizms
High-roller
 
thefatshizms's Avatar
 
Join Date: Dec 2011
Location: England
Posts: 1,745
Reputation: 259
Default Mysql | Always wrong password

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;
}
thefatshizms is offline   Reply With Quote
Old 23/01/2013, 05:59 PM   #2
Sweez
Huge Clucker
 
Join Date: Apr 2012
Location: Varna, Bulgaria/ Варна, Българ
Posts: 347
Reputation: 3
Default Re: Mysql | Always wrong password

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 !
__________________
Bulgarian Mafia RolePlay Comming back soon
Sweez is offline   Reply With Quote
Old 23/01/2013, 07:07 PM   #3
thefatshizms
High-roller
 
thefatshizms's Avatar
 
Join Date: Dec 2011
Location: England
Posts: 1,745
Reputation: 259
Default Re: Mysql | Always wrong password

All you have changed is the colour ...
thefatshizms is offline   Reply With Quote
Old 23/01/2013, 07:16 PM   #4
FUNExtreme
Gangsta
 
Join Date: Mar 2008
Posts: 790
Reputation: 128
Default Re: Mysql | Always wrong password

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, ..
__________________

FUNExtreme is offline   Reply With Quote
Old 23/01/2013, 07:21 PM   #5
thefatshizms
High-roller
 
thefatshizms's Avatar
 
Join Date: Dec 2011
Location: England
Posts: 1,745
Reputation: 259
Default Re: Mysql | Always wrong password

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.
thefatshizms is offline   Reply With Quote
Old 23/01/2013, 07:23 PM   #6
FUNExtreme
Gangsta
 
Join Date: Mar 2008
Posts: 790
Reputation: 128
Default Re: Mysql | Always wrong password

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.
__________________

FUNExtreme is offline   Reply With Quote
Old 23/01/2013, 07:46 PM   #7
thefatshizms
High-roller
 
thefatshizms's Avatar
 
Join Date: Dec 2011
Location: England
Posts: 1,745
Reputation: 259
Default Re: Mysql | Always wrong password

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)
thefatshizms is offline   Reply With Quote
Old 23/01/2013, 07:51 PM   #8
DanLore
Big Clucker
 
DanLore's Avatar
 
Join Date: Jan 2013
Posts: 99
Reputation: 19
Default Re: Mysql | Always wrong password

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..
DanLore is offline   Reply With Quote
Old 23/01/2013, 08:13 PM   #9
thefatshizms
High-roller
 
thefatshizms's Avatar
 
Join Date: Dec 2011
Location: England
Posts: 1,745
Reputation: 259
Default Re: Mysql | Always wrong password

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
thefatshizms is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
You can login with any password, and it's never wrong? Please help Goldino Scripting Help 16 23/01/2013 04:51 PM
mysql enters wrong password in the database Logan_Adams Scripting Help 1 31/10/2012 10:41 PM
Wrong Password Norhy Scripting Help 0 17/10/2012 11:01 AM
strcmp, wrong password... Itzhak E. Scripting Help 6 07/04/2012 07:51 PM
Wrong Password Master_FM Help Archive 7 03/03/2011 04:32 PM


All times are GMT. The time now is 07:15 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.