Crash Detect - SQL Help.
#1

This is my Crash Detect:

The issue I have is, I can register my account through MySQL, but when I login, it crashes my server.
I have no idea what I did wrong.


Code:
[16:34:03] [debug] Server crashed while executing NTDM.amx
[16:34:03] [debug] AMX backtrace:
[16:34:03] [debug] #0 native mysql_fetch_field_row () [b74e87a0] from mysql.so
[16:34:03] [debug] #1 0000dc00 in ?? (0x00000000) from NTDM.amx
[16:34:03] [debug] #2 0000cb34 in public OnDialogResponse (0x00000000, 0x00000001, 0x00000001, 0xffffffff, 0x00014754) from NTDM.amx
[16:34:03] [debug] Native backtrace:
[16:34:03] [debug] #0 b685909b in _ZN10StackTraceC1EPv () from plugins/crashdetect.so
[16:34:03] [debug] #1 b68542d2 in _ZN11CrashDetect20PrintNativeBacktraceERSoPv () from plugins/crashdetect.so
[16:34:03] [debug] #2 b6854ebc in _ZN11CrashDetect20PrintNativeBacktraceEPv () from plugins/crashdetect.so
[16:34:03] [debug] #3 b6855366 in _ZN11CrashDetect11OnExceptionEPv () from plugins/crashdetect.so
[16:34:03] [debug] #4 b6858cec in ?? () from plugins/crashdetect.so
[16:34:03] [debug] #5 b77c2600 in ?? ()
[16:34:03] [debug] #6 b75851f6 in ?? () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[16:34:03] [debug] #7 b7760073 in _ZNKSs7compareEPKc () from /usr/lib/i386-linux-gnu/libstdc++.so.6
[16:34:03] [debug] #8 b74e3973 in _ZN13CMySQLHandler10FetchFieldESs () from plugins/mysql.so
[16:34:03] [debug] #9 b74e8820 in _ZN7Natives23n_mysql_fetch_field_rowEP6tagAMXPi () from plugins/mysql.so
[16:34:03] [debug] #10 08093f54 in ?? () from ./samp03svr
[16:34:03] [debug] #11 b6851b9c in _ZN11CrashDetect13DoAmxCallbackEiPiS0_ () from plugins/crashdetect.so
[16:34:03] [debug] #12 b6857d38 in ?? () from plugins/crashdetect.so
[16:34:03] [debug] #13 b685e1f8 in amx_Exec () from plugins/crashdetect.so
[16:34:03] [debug] #14 b6854218 in _ZN11CrashDetect9DoAmxExecEPii () from plugins/crashdetect.so
[16:34:03] [debug] #15 b6857aa9 in ?? () from plugins/crashdetect.so
[16:34:03] [debug] #16 080a505f in ?? () from ./samp03svr
[16:34:03] [debug] #17 080b0ea4 in ?? () from ./samp03svr
[16:34:03] [debug] #18 08071af8 in ?? () from ./samp03svr
[16:34:03] [debug] #19 08071bf2 in ?? () from ./samp03svr
[16:34:03] [debug] #20 0807bab0 in ?? () from ./samp03svr
[16:34:03] [debug] #21 080ad09d in ?? () from ./samp03svr
[16:34:03] [debug] #22 080ad242 in ?? () from ./samp03svr
[16:34:03] [debug] #23 080a85ce in ?? () from ./samp03svr
[16:34:03] [debug] #24 b751be46 in __libc_start_main () from /lib/i386-linux-gnu/i686/cmov/libc.so.6
[16:34:03] [debug] #25 0804b4a1 in ?? () from ./samp03svr
pawn Code:
PF:GameModeInit()
{
      mysql_debug(1);
    mysql_connect(mysql_host, mysql_user, mysql_database, mysql_password);
    mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(41), score INT(20), money INT(20), IP VARCHAR(16) )");
pawn Code:
PF:OnPlayerConnect(playerid)
{
    MoneyGiven[playerid] = -1;
    new query[200], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT IP FROM `playerdata` WHERE user = '%s' LIMIT 1", pname); //Formats the query, view above the code for a explanation
    mysql_query(query);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(!rows)
    {
        ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Register","Your user is {FF0000}not{FFFFFF} registered! Please {0000FF}register{FFFFFF} with a password below!","Register","Cancel"); //Shows our register dialog :).
    }
    if(rows == 1)
    {
        new IP[2][16]; //
        mysql_fetch_field_row(IP[0],"IP");
        GetPlayerIp(playerid, IP[1], 16);
        if(strlen(IP[0]) != 0 && !strcmp(IP[0], IP[1], true))
        {
            MySQL_Login(playerid);
            printf("Starting Login");
        }
        else if(!strlen(IP[0]) || strcmp(IP[0], IP[1], true))
        {
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login","Your user is {FF0000}registered{FFFFFF}! Please {0000FF}login{FFFFFF} with your password below!","Login","Cancel"); //Shows our login dialog :).
            IsRegistered[playerid] = 1;
        }
    }
    mysql_free_result();
    return 1;
}
pawn Code:
PF: OnPlayerDisconnect(playerid, reason)
{
    if(Logged[playerid] == 1)
    {
        new score = GetPlayerScore(playerid);
        new money = GetPlayerMoney(playerid);
        new query[200], pname[24];
        GetPlayerName(playerid, pname, 24); //
        format(query, sizeof(query), "UPDATE playerdata SET score=%d, money=%d WHERE user='%s'", score, money, pname);
        mysql_query(query);
    }
    return 1;
}
pawn Code:
stock MySQL_Login(playerid)
{
    printf("Login stock loaded");
    new query[300], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
    printf("Login Function Select Name");
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        printf("Login Function Variable Loading");
        mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
        printf("Login Function Variable Loading - Score");
        printf("Login Function Variable Loading - Money");
    }
    mysql_free_result();
    printf("Login Function Variable Loading - Freeing Result");
    SendClientMessage(playerid, -1, "You have been logged in!");
    Logged[playerid] = 1;
    return 1;
}
pawn Code:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[200], pname[24], IP[16];
    GetPlayerName(playerid, pname, 24);
    GetPlayerIp(playerid, IP, 16);
    format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, IP) VALUES('%s', SHA1('%s'), 0, 0, '%s')", pname, passwordstring, IP);
    mysql_query(query);
    SendClientMessage(playerid, -1, "You have been registered on this server!");
    Logged[playerid] = 1; //Sets the login variable
    return 1;
}
pawn Code:
PF: OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 0) //If Dialog is our register dialog
    {
        if(response) //If they click the button register
        {
            if(!strlen(inputtext) || strlen(inputtext) > 100)  //Password is not 1 to 100 characters
            {
                SendClientMessage(playerid, 0xFF0000, "You must insert a password between 1-100 characters!"); //Sends the client a error message
                ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Register","Your user is {FF0000}not{FFFFFF} registered! Please {0000FF}register{FFFFFF} with a password below!\n {FF0000}ERROR:Please enter a password between 1-100 characters!","Register","Cancel"); //Shows our register dialog :).
            }
            else if(strlen(inputtext) > 0 && strlen(inputtext) < 100)
            {
                new escpass[100];
                mysql_real_escape_string(inputtext, escpass);
                MySQL_Register(playerid, escpass);
            }
        }
        if(!response)
        {
                SendClientMessage(playerid, 0xFF0000, "You must register before logging in!"); //Sends the client a error message
                ShowPlayerDialog(playerid, 15000, DIALOG_STYLE_INPUT, "Register","Your user is {FF0000}not{FFFFFF} registered! Please {0000FF}register{FFFFFF} with a password below!\n {FF0000}ERROR:Please enter a password !","Register","Cancel"); //Shows our register dialog :).
        }
    }
    if(dialogid == 1) //Dialog login
    {
        if(!response) //If they click the cancel button
        {
                SendClientMessage(playerid, 0xFF0000, "You must login before you spawn!"); //Sends the client a error message
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Login","Your user is {FF0000}registered{FFFFFF}! Please {0000FF}login{FFFFFF} with your password below!\n{FF0000} You must login before you spawn!","Login","Cancel"); //Shows our login dialog :).
        }
        if(response) //If the player clicked login
        {
            new query[200], pname[24], escapepass[100]; //
            GetPlayerName(playerid, pname, 24); //Gets the players name
            printf("name string");
            mysql_real_escape_string(inputtext, escapepass); //We escape the inputtext to avoid SQL injections.
            printf("escape string");
            format(query, sizeof(query), "SELECT `user` FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", pname, escapepass);
            printf(query);
            mysql_query(query);
            mysql_store_result();
            new numrows = mysql_num_rows();
            if(numrows == 1) MySQL_Login(playerid);
            if(!numrows)
            {
                ShowPlayerDialog(playerid, 15500, DIALOG_STYLE_INPUT, "Login","Your user is {FF0000}registered{FFFFFF}! Please {0000FF}login{FFFFFF} with your password below!\n{FF0000} The password you typed was incorrect!","Login","Cancel"); //Shows our login dialog :).
                SendClientMessage(playerid, 0xFF0000, "Incorrect password!"); //Sends the client a error message
            }
            mysql_free_result(); //Remember to always free a result if you stored one!
        }
Reply
#2

Anyone?
Reply
#3

Did you check brackets.. because it looks like you miss some of it.. This says it AMX backtrace:

+ show load function...

+ which mysql plugin you are using?
Reply
#4

All my brackets are there.
If they weren't, I wouldn't be able to run the server at all as it'd send warnings / errors in Pawn.
But I double checked and yes, they're all there.

SQL by BlueG

and the Load function is there....Mysql_Login
Reply
#5

Oke so show the loading function + say which mysql version you are using?
Reply
#6

R6, Debian 5
Reply
#7

Btw it looks more like plugin error not systems or scripting error.. Try to contact them.. Because as I red about your error in ****** ( mysql_fetch_field_row () [b74e87a0]) It is about mysql plugin error!
Reply
#8

FIXED: Used R5 Plugin instead of R6
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)