SA-MP Forums Archive
MySQL connection handle. - 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: MySQL connection handle. (/showthread.php?tid=409610)



MySQL connection handle. - BaubaS - 22.01.2013

Quote:

[16:45:12] >> mysql_format( Connection handle: 76 )
[16:45:12] >> mysql_format() - Invalid connection handle. (You set: 76, Highest connection handle ID is 1).
[16:45:12] >> mysql_query_callback( Connection handle: 76 )
[16:45:12] >> mysql_query_callback() - Invalid connection handle. (You set: 76, Highest connection handle ID is 1).
[16:45:31] >> mysql_format( Connection handle: 76 )
[16:45:31] >> mysql_format() - Invalid connection handle. (You set: 76, Highest connection handle ID is 1).
[16:45:31] >> mysql_query_callback( Connection handle: 76 )
[16:45:31] >> mysql_query_callback() - Invalid connection handle. (You set: 76, Highest connection handle ID is 1).
[16:45:31] >> mysql_close( Connection handle: 76 )
[16:45:31] >> mysql_close() - Invalid connection handle. (You set: 76, Highest connection handle ID is 1).

Hello. Today I wanted to test some of my scripts, the problem is that whole mysql system is being ruint because connection handle somewhy changes when a player connects. I've did some debugs:


pawn Код:
stock ConnectToMySQL()
{
    mysqlHandle = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
    mysql_debug(true);
   
    printf("Handle # OGI # 1: %d", mysqlHandle);

    if (mysqlHandle > 0)
    {
        // connect success
        printf("Handle # OGI # 2: %d" mysqlHandle);
    }
   
    else
    {
        // something wrong with the connection
        printf("Handle # OGI # 3: %d", mysqlHandle);
        SendRconCommand("exit");
        return (true);
    }
   
    printf("Handle # OGI # 4: %d", mysqlHandle);
   
    return (true);
}
pawn Код:
public OnPlayerConnect(playerid)
{
    printf("Handle # OPC # 1: %d", mysqlHandle);
           <...> code
    printf("Handle # OPC # 2: %d", mysqlHandle);
    return (true);
}
pawn Код:
Hook:user_OnPlayerConnect(playerid)
{
    printf("Handle # OPC # 3: %d", mysqlHandle);
    <..>code
    printf("Handle # OPC # 4: %d", mysqlHandle);
    return (true);
}
Results:

Quote:

[16:44:35] Handle # OGI # 1: 1
[16:44:35] Handle # OGI # 2: 1
[16:44:35] Handle # OGI # 4: 1
[16:45:08] Handle # OPC # 3: 76
[16:45:08] Handle # OPC # 4: 76
[16:45:08] Handle # OPC # 1: 76
[16:45:08] Handle # OPC # 2: 76
[16:45:11] Handle # OPC # 5: 76
[16:45:11] Handle # OPC # 6: 76
[16:45:12] Handle # OPC # 7: 76
[16:45:12] Handle # OPC # 8: 76




Re: MySQL connection handle. - BaubaS - 22.01.2013

Bump


Re: MySQL connection handle. - denNorske - 22.01.2013

Quote:

Note: Every function except mysql_connect(...) and mysql_debug() has connectionHandle parameter. If you use only one database connection you don't need to mind it. Connection handle is 1 by default.

Any help for you? :P (read it on the wiki) Check your scripts for the value 76, and find the lines that might interfere with your codes.


Re: MySQL connection handle. - BaubaS - 22.01.2013

Okay, I thought its changed in R7 plugin, anyway I'll try. Thank you.