SA-MP Forums Archive
Login/Register MySQL not working - 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: Login/Register MySQL not working (/showthread.php?tid=363320)



Login/Register MySQL not working - SEnergy - 27.07.2012

edit: well login/register is working so far, but I have this error: I can enter ANY password to login, any suggestions?

PHP код:
    if(dialogid == iLoginDialog)
    {
        if(
response)
        {
            if(
strlen(inputtext) > 0)
            {
                new 
EscapedText[60];
                
mysql_real_escape_string(inputtextEscapedText);
                new 
len strlen(EscapedText);
                
format(Querysizeof(Query), "SELECT `Password` FROM `RL` WHERE `Username` = '%s';"pName);
                
mysql_query(Query);
                new 
result[60];
                
mysql_fetch_field_row(result"Password");
                if(
strcmp(EscapedTextresulttruelen) == 0)
                {
                    
TogglePlayerSpectating(playeridfalse);
                    return 
1;
                }
            }
            
ShowPlayerDialog(playeridiLoginDialogDIALOG_STYLE_PASSWORD"Login""Enter Your Password!""Login""Cancel");
        }
        else
            return 
0;
    } 



Re: Login/Register MySQL not working - Misiur - 27.07.2012

Put this under mysql_query in OnPlayerConnect
pawn Код:
printf("User %d looked up in database with response %d", playerid, mysql_errno());
After you connect this will pop up in server console - if the response is diffrent than 0, then query returned an error.

On a sidenote: You've forgotten about executing query in login dialog.


Re: Login/Register MySQL not working - SEnergy - 27.07.2012

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Put this under mysql_query in OnPlayerConnect
pawn Код:
printf("User %d looked up in database with response %d", playerid, mysql_errno());
After you connect this will pop up in server console - if the response is diffrent than 0, then query returned an error.

On a sidenote: You've forgotten about executing query in login dialog.
response 2005, what now?


Re: Login/Register MySQL not working - Misiur - 27.07.2012

Quote:

ERROR 2005 (HY000): Unknown MySQL server host 'XXX'

Your connection host is invalid


Re: Login/Register MySQL not working - SEnergy - 27.07.2012

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Your connection host is invalid
my connection host is the same I'm using for my website, which is working fine, I guess I'll have to install mysql on pc ;/

edit: it's working, thanks!

edit2: well, I can enter ANY password to login, any suggestions?

PHP код:
    if(dialogid == iLoginDialog)
    {
        if(
response)
        {
            if(
strlen(inputtext) > 0)
            {
                new 
EscapedText[60];
                
mysql_real_escape_string(inputtextEscapedText);
                new 
len strlen(EscapedText);
                
format(Querysizeof(Query), "SELECT `Password` FROM `RL` WHERE `Username` = '%s';"pName);
                
mysql_query(Query);
                new 
result[60];
                
mysql_fetch_field_row(result"Password");
                if(
strcmp(EscapedTextresulttruelen) == 0)
                {
                    
TogglePlayerSpectating(playeridfalse);
                    return 
1;
                }
            }
            
ShowPlayerDialog(playeridiLoginDialogDIALOG_STYLE_PASSWORD"Login""Enter Your Password!""Login""Cancel");
        }
        else
            return 
0;
    } 



Re: Login/Register MySQL not working - doreto - 27.07.2012

You cant use website datebase for home server


Re: Login/Register MySQL not working - SEnergy - 27.07.2012

bump?