Crash when player connects - MySQL.
#1

When a player joins the server and has a registered account, the server crashes, however this doesn't occur when the player doesn't have an account. Seems to be with 'mysql_fetch_field_row'.

Quote:

[18:48:38] [debug] #1 000f75dc in OnQueryFinish () from LGRP.amx
[18:48:38] [debug] #0 ?? in native mysql_fetch_field_row () from mysql.so
[18:48:38] [debug] Backtrace (most recent call first):
[18:48:38] [debug] Server crashed while executing LGRP.amx

Edit: No longer relevant.
Reply
#2

Hello.

That is quite a big query there. I can't seem to find something that looks wrong on it, and since the part that processes the result is such a long piece of code, I'd recommend you try debugging and eliminating the problem.

First:
Change
pawn Код:
//found in your query result processing code
    switch(resultid)
    {
        case THREAD_USERNAME_LOOKUP:
        {
            // We need to store the result in memory. This may be multiple rows, or 1, or even none. But we haven't checked yet, but we can now.
            mysql_store_result(connectionHandle);

            if(mysql_num_rows(connectionHandle) > 0)
            {
to
pawn Код:
//found in your query result processing code
    switch(resultid)
    {
        case THREAD_USERNAME_LOOKUP:
        {
            // We need to store the result in memory. This may be multiple rows, or 1, or even none. But we haven't checked yet, but we can now.
            mysql_store_result(connectionHandle);
            /*
            if(mysql_num_rows(connectionHandle) > 0)
            {
and change
pawn Код:
//Found in your query processing code
                // We're setting the status to 2 here. The player hasn't logged in yet, but we're getting the information now so we don't have to later.
                PlayerInfo[extraid][pStatus] = 2;

                // In most languages, using mysql_free_result can seem insignificant. However, in PAWN, with the plugins we have available, the best thing to do is to use this when you've finished
                // with some data from MySQL. You only need to use mysql_free_result when you're dealing with SELECT queries or any other query that is designed to return information.
                mysql_free_result(connectionHandle);
                format(szMessage, sizeof(szMessage), "SERVER: This account (%s) is registered. Please enter the account password to login, otherwise please pick another name.", PlayerInfo[extraid][pUsername]);
                SendClientMessage(extraid, COLOR_YELLOW, szMessage);

                format(string,sizeof(string), "Welcome to Liberation Group Roleplay, %s.\n\nIP: %s\n\nThe account you are using is registered, please enter your password to login.", GetPlayerNameEx(extraid), PlayerInfo[extraid][pIP]);
                ShowPlayerDialog(extraid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{0049FF}Liberation Group Roleplay Login", string,"Login","Quit");

            }
to
pawn Код:
//Found in your query processing code
                // We're setting the status to 2 here. The player hasn't logged in yet, but we're getting the information now so we don't have to later.
                PlayerInfo[extraid][pStatus] = 2;
                */
                // In most languages, using mysql_free_result can seem insignificant. However, in PAWN, with the plugins we have available, the best thing to do is to use this when you've finished
                // with some data from MySQL. You only need to use mysql_free_result when you're dealing with SELECT queries or any other query that is designed to return information.
                mysql_free_result(connectionHandle);/*
                format(szMessage, sizeof(szMessage), "SERVER: This account (%s) is registered. Please enter the account password to login, otherwise please pick another name.", PlayerInfo[extraid][pUsername]);
                SendClientMessage(extraid, COLOR_YELLOW, szMessage);

                format(string,sizeof(string), "Welcome to Liberation Group Roleplay, %s.\n\nIP: %s\n\nThe account you are using is registered, please enter your password to login.", GetPlayerNameEx(extraid), PlayerInfo[extraid][pIP]);
                ShowPlayerDialog(extraid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"{0049FF}Liberation Group Roleplay Login", string,"Login","Quit");
                */

                SendClientMessage(extraid,0xFF0000FF,"Test complete. Query ran without crash");
            }
This will basically disable all the code that recovers the information received from the query.
Ignore any warnings you may get about "Nested comments" and compile the code.

Now connect with a registered account and see if you still crash.
If you crash, the problem is caused by something before this point.
If you don't crash, then there is something in your code which recovers the query information which is causing the crash.
Reply
#3

Okay, the query ran when I blocked out all this part of the code; so the problem persists somewhere in this part, however I don't know what/where it is?;

Edit: No longer relevant.
Reply
#4

Ah that's good news.

Now the way to find out what is causing the problem is to move the "/*" further down the section of code, which will result in more of the code being called and eventually, the query failing.

Now since your code is so long, it would take forever if we were to move one part at a time, so first I'd recommend you make sure you can recover at least one piece of data like this:
pawn Код:
if(mysql_num_rows(connectionHandle) > 0)
    {
        mysql_retrieve_row();

        new szReturn[128];

                mysql_fetch_field_row(PlayerInfo[extraid][pPass], "Password", connectionHandle);
        /*
                mysql_fetch_field_row(szReturn, "ID", connectionHandle);
                PlayerInfo[extraid][pDBID] = strval(szReturn);
and then if this works, move it to about half way down the code
Reply
#5

Okay, that was easy to find out as it was the first one, 'Password' should have been 'Pass' . However, the server doesn't seem to load data, I get incorrect password on login and when I made a temporary, any password will work, I spawned at 0, 0, 0 with 0 health and none of the stats were their (admin etc.). Any solution? I can't see why it wouldn't work. :/

EDIT: Fixed - Password string wasn't long enough :3 Positions were floats, changed to strings (Database).
Thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)