SA-MP Forums Archive
MySQL Error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: MySQL Error (/showthread.php?tid=475631)



MySQL Error - Tingesport - 14.11.2013

When I try to start up my server it says..

Код:
[10:45:04]  

[10:45:04] ---------------------------

[10:45:04] MySQL Debugging activated (11/14/13)

[10:45:04] ---------------------------

[10:45:04]  

[10:45:04] >> mysql_connect( )

[10:45:04] CMySQLHandler::CMySQLHandler() - constructor called.

[10:45:04] CMySQLHandler::CMySQLHandler() - Connecting to "BLURRED" | DB: "BLURRED" | Username: "BLURRED" ...

[10:45:04] CMySQLHandler::Connect() - Connection was successful.

[10:45:04] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.

[10:45:04] >> mysql_query( Connection handle: 1 )

[10:45:04] CMySQLHandler::Query(resultID) - Threaded query with id 1 started. (Extra ID: -1)

[10:45:04] CMySQLHandler::ProcessQueryThread() - Error will be triggered to OnQueryError()
And yes, I blurred out the hostname, database and username, I'm aware of that.


Re: MySQL Error - Konstantinos - 14.11.2013

Add (if not exists already) OnQueryError to your script and print the parameters (debugging).


Re: MySQL Error - Tingesport - 14.11.2013

Код:
[11:51:15] [debug] Server crashed while executing BLURRED.amx
[11:51:15] [debug] AMX backtrace:
[11:51:15] [debug] #0 native fclose () [004056c0] from samp-server.exe
[11:51:15] [debug] #1 0002af04 in public LoadRefundCars () from BLURRED.amx
[11:51:15] [debug] #2 0002ecd0 in public zcmd_OnGameModeInit () from BLURRED.amx
[11:51:15] [debug] #3 native CallLocalFunction () [00471ef0] from samp-server.exe
[11:51:15] [debug] #4 000081b8 in public SSCANF_OnGameModeInit () from BLURRED.amx
[11:51:15] [debug] #5 000021d8 in public Itter_OnGameModeInit () from BLURRED.amx
[11:51:15] [debug] #6 native CallLocalFunction () [00471ef0] from samp-server.exe
[11:51:15] [debug] #7 000019c4 in public ScriptInit_OnGameModeInit () from BLURRED.amx
[11:51:15] [debug] #8 00000bb8 in public OnGameModeInit () from BLURRED.amx
[11:51:15] [debug] Native backtrace:
[11:51:15] [debug] #0 0049316b in ?? () from BLURRED
[11:51:15] [debug] #1 004056cd in ?? () from BLURRED
[11:51:15] [debug] #2 6b7560ba in ?? () from BLURRED
[11:51:15] [debug] #3 6b757fee in ?? () from BLURRED
[11:51:15] [debug] #4 6b750091 in ?? () from BLURRED
[11:51:15] [debug] #5 6b75610a in ?? () from BLURRED
[11:51:15] [debug] #6 004721fe in ?? () from BLURRED
[11:51:15] [debug] #7 004010b6 in ?? () from BLURRED
[11:51:15] [debug] #8 6b7560ba in ?? () from BLURRED
[11:51:15] [debug] #9 6b757fee in ?? () from BLURRED
[11:51:15] [debug] #10 6b750091 in ?? () from BLURRED
[11:51:15] [debug] #11 6b75610a in ?? () from BLURRED
[11:51:15] [debug] #12 004721fe in ?? () from BLURRED
[11:51:15] [debug] #13 004010b6 in ?? () from BLURRED
[11:51:15] [debug] #14 6b7560ba in ?? () from BLURRED
[11:51:15] [debug] #15 6b757fee in ?? () from BLURRED
[11:51:15] [debug] #16 6b750091 in ?? () from BLURRED
[11:51:15] [debug] #17 6b75610a in ?? () from BLURRED
[11:51:15] [debug] #18 0046e1f4 in ?? () from BLURRED
[11:51:15] [debug] #19 65646f6d in ?? () from BLURRED
[11:51:15] [debug] #20 414c2f73 in ?? () from BLURRED
[11:51:15] [debug] #21 2e50522d in ?? () from BLURRED
[11:51:15] [debug] #22 00786d61 in ?? ()



Re: MySQL Error - Konstantinos - 14.11.2013

Post LoadRefundCars function, fclose that was used in it crashed the server (probably not checking if the file opened successfully).


Re: MySQL Error - Tingesport - 14.11.2013

pawn Код:
public LoadRefundCars()
{
    new arrCoords[42][64];
    new strFromFile2[256];
    new File: file = fopen("cars2.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(RefundcInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            RefundcInfo[idx][rcModel] = strval(arrCoords[0]);
            RefundcInfo[idx][rcLocationx] = floatstr(arrCoords[1]);
            RefundcInfo[idx][rcLocationy] = floatstr(arrCoords[2]);
            RefundcInfo[idx][rcLocationz] = floatstr(arrCoords[3]);
            RefundcInfo[idx][rcAngle] = floatstr(arrCoords[4]);
            RefundcInfo[idx][rcColorOne] = strval(arrCoords[5]);
            RefundcInfo[idx][rcColorTwo] = strval(arrCoords[6]);
            strmid(RefundcInfo[idx][rcOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(RefundcInfo[idx][rcDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            RefundcInfo[idx][rcValue] = strval(arrCoords[9]);
            RefundcInfo[idx][rcLicense] = strval(arrCoords[10]);
            RefundcInfo[idx][rcOwned] = strval(arrCoords[11]);
            RefundcInfo[idx][rcLock] = strval(arrCoords[12]);
            RefundcInfo[idx][rcMod][0] = strval(arrCoords[13]);
            RefundcInfo[idx][rcMod][1] = strval(arrCoords[14]);
            RefundcInfo[idx][rcMod][2] = strval(arrCoords[15]);
            RefundcInfo[idx][rcMod][3] = strval(arrCoords[16]);
            RefundcInfo[idx][rcMod][4] = strval(arrCoords[17]);
            RefundcInfo[idx][rcMod][5] = strval(arrCoords[18]);
            RefundcInfo[idx][rcMod][6] = strval(arrCoords[19]);
            RefundcInfo[idx][rcMod][7] = strval(arrCoords[20]);
            RefundcInfo[idx][rcMod][8] = strval(arrCoords[21]);
            RefundcInfo[idx][rcMod][9] = strval(arrCoords[22]);
            RefundcInfo[idx][rcDonate] = strval(arrCoords[23]);
            RefundcInfo[idx][rcFuel] = strval(arrCoords[24]);
            RefundcInfo[idx][rcTrunkWep][1] = strval(arrCoords[25]);
            RefundcInfo[idx][rcTrunkAmmo][1] = strval(arrCoords[26]);
            RefundcInfo[idx][rcTrunkWep][2] = strval(arrCoords[27]);
            RefundcInfo[idx][rcTrunkAmmo][2] = strval(arrCoords[28]);
            RefundcInfo[idx][rcTrunkWep][3] = strval(arrCoords[29]);
            RefundcInfo[idx][rcTrunkAmmo][3] = strval(arrCoords[30]);
            RefundcInfo[idx][rcTrunkWep][4] = strval(arrCoords[31]);
            RefundcInfo[idx][rcTrunkAmmo][4] = strval(arrCoords[32]);
            RefundcInfo[idx][rcTrunkArmour] = floatstr(arrCoords[33]);
            RefundcInfo[idx][rcTrunkCounter] = strval(arrCoords[34]);
            RefundcInfo[idx][rcAlarm] = strval(arrCoords[35]);
            RefundcInfo[idx][rcTrunkDrugs] = strval(arrCoords[36]);
            RefundcInfo[idx][rcTrunkMats] = strval(arrCoords[37]);
            RefundcInfo[idx][rcImpounded] = strval(arrCoords[38]);
            RefundcInfo[idx][rcImpoundedPrice] = strval(arrCoords[39]);
            RefundcInfo[idx][rcInsur] = strval(arrCoords[40]);
            RefundcInfo[idx][rcHealth] = floatstr(arrCoords[41]);
            idx++;
        }
    }
    fclose(file);
    return 1;
}



Re: MySQL Error - Konstantinos - 14.11.2013

The fclose function must be inside the "if (file)" statement (so it can know that it opened the file successully so it can close it ) and outside of the while loop. If the file failed to open for any reason and it tries to close an already closed file, the result will be crash.

So change to:
pawn Код:
public LoadRefundCars()
{
    new arrCoords[42][64];
    new strFromFile2[256];
    new File: file = fopen("cars2.cfg", io_read);
    if (file)
    {
        new idx;
        while (idx < sizeof(RefundcInfo))
        {
            fread(file, strFromFile2);
            split(strFromFile2, arrCoords, ',');
            RefundcInfo[idx][rcModel] = strval(arrCoords[0]);
            RefundcInfo[idx][rcLocationx] = floatstr(arrCoords[1]);
            RefundcInfo[idx][rcLocationy] = floatstr(arrCoords[2]);
            RefundcInfo[idx][rcLocationz] = floatstr(arrCoords[3]);
            RefundcInfo[idx][rcAngle] = floatstr(arrCoords[4]);
            RefundcInfo[idx][rcColorOne] = strval(arrCoords[5]);
            RefundcInfo[idx][rcColorTwo] = strval(arrCoords[6]);
            strmid(RefundcInfo[idx][rcOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
            strmid(RefundcInfo[idx][rcDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
            RefundcInfo[idx][rcValue] = strval(arrCoords[9]);
            RefundcInfo[idx][rcLicense] = strval(arrCoords[10]);
            RefundcInfo[idx][rcOwned] = strval(arrCoords[11]);
            RefundcInfo[idx][rcLock] = strval(arrCoords[12]);
            RefundcInfo[idx][rcMod][0] = strval(arrCoords[13]);
            RefundcInfo[idx][rcMod][1] = strval(arrCoords[14]);
            RefundcInfo[idx][rcMod][2] = strval(arrCoords[15]);
            RefundcInfo[idx][rcMod][3] = strval(arrCoords[16]);
            RefundcInfo[idx][rcMod][4] = strval(arrCoords[17]);
            RefundcInfo[idx][rcMod][5] = strval(arrCoords[18]);
            RefundcInfo[idx][rcMod][6] = strval(arrCoords[19]);
            RefundcInfo[idx][rcMod][7] = strval(arrCoords[20]);
            RefundcInfo[idx][rcMod][8] = strval(arrCoords[21]);
            RefundcInfo[idx][rcMod][9] = strval(arrCoords[22]);
            RefundcInfo[idx][rcDonate] = strval(arrCoords[23]);
            RefundcInfo[idx][rcFuel] = strval(arrCoords[24]);
            RefundcInfo[idx][rcTrunkWep][1] = strval(arrCoords[25]);
            RefundcInfo[idx][rcTrunkAmmo][1] = strval(arrCoords[26]);
            RefundcInfo[idx][rcTrunkWep][2] = strval(arrCoords[27]);
            RefundcInfo[idx][rcTrunkAmmo][2] = strval(arrCoords[28]);
            RefundcInfo[idx][rcTrunkWep][3] = strval(arrCoords[29]);
            RefundcInfo[idx][rcTrunkAmmo][3] = strval(arrCoords[30]);
            RefundcInfo[idx][rcTrunkWep][4] = strval(arrCoords[31]);
            RefundcInfo[idx][rcTrunkAmmo][4] = strval(arrCoords[32]);
            RefundcInfo[idx][rcTrunkArmour] = floatstr(arrCoords[33]);
            RefundcInfo[idx][rcTrunkCounter] = strval(arrCoords[34]);
            RefundcInfo[idx][rcAlarm] = strval(arrCoords[35]);
            RefundcInfo[idx][rcTrunkDrugs] = strval(arrCoords[36]);
            RefundcInfo[idx][rcTrunkMats] = strval(arrCoords[37]);
            RefundcInfo[idx][rcImpounded] = strval(arrCoords[38]);
            RefundcInfo[idx][rcImpoundedPrice] = strval(arrCoords[39]);
            RefundcInfo[idx][rcInsur] = strval(arrCoords[40]);
            RefundcInfo[idx][rcHealth] = floatstr(arrCoords[41]);
            idx++;
        }
        fclose(file);
    }
    return 1;
}



Re: MySQL Error - Tingesport - 14.11.2013

It worked, thank you! Got another problem, the server starts but it connects to grand larceny and the server.cfg is configured correctly?


Re: MySQL Error - Konstantinos - 14.11.2013

Post the server.cfg (hide the RCON password).


Re: MySQL Error - Tingesport - 14.11.2013

GOT IT WORKING