open.mp forum
[Pawn] invalid connection handle - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
+--- Thread: [Pawn] invalid connection handle (/showthread.php?tid=742)



invalid connection handle - IdontMIss - 2019-08-04

I started scripting a fresh new TDM script from 0 and I wanted to try out the bcyrpt hashing alg and everything went fine I created a register/login system but when I wanted to test it next things happend:

myScript:
Code:
public OnPlayerConnect(playerid) {     new query[256];     mysql_format(SQL, query, sizeof query, "SELECT * FROM `players` WHERE `name`='%e' LIMIT 1", GetPlayerNameEx(playerid)); // 9     mysql_pquery(SQL, query, "OnAccountCheck", "i", playerid); // 10     #if defined reg_OnPlayerConnect         return reg_OnPlayerConnect(playerid);     #else         return true;     #endif } #if defined _ALS_OnPlayerConnect     #undef OnPlayerConnect #else     #define _ALS_OnPlayerConnect #endif #define OnPlayerConnect reg_OnPlayerConnect #if defined reg_OnPlayerConnect     forward reg_OnPlayerConnect(playerid); #endif

The errors I get in mysql
Code:
[INFO] changed log level from 'warning, error' to 'debug, info, warning, error' [DEBUG] CThreadedConnection::WorkerFunc(this=0x41ea020, connection=0x41ea020) [DEBUG] mysql_format(111, 0x0307AF98, 256, "SELECT * FROM `players` WHERE `name` = '%e'") (modules/register.pwn:10) [ERROR] mysql_format: invalid connection handle '111' (modules/register.pwn:10) [DEBUG] mysql_pquery(111, "", "OnAccountCheck", "i") (modules/register.pwn:11) [ERROR] mysql_pquery: invalid connection handle '111' (modules/register.pwn:11) [DEBUG] mysql_pquery: return value: '0' (modules/register.pwn:11)

EDIT: I use R41-4 and this happens after OnGameModeInit, and my connection is successful


RE: invalid connection handle - IdontMIss - 2019-08-04

For some reason my connection handle changes?

Code:
    new q[256];     printf("%d // 1", _:SQL);     mysql_format(1, q, sizeof q, "SELECT * FROM `players` WHERE `name`='%e' LIMIT 1", GetPlayerNameEx(playerid));     printf("%d // 2", _:SQL);     mysql_pquery(1, q, "OnAccountCheck", "i", playerid);     printf("%d // 3", _:SQL);
Returns:

Code:
1 // 1 111 // 2 111 // 3



RE: invalid connection handle - IdontMIss - 2019-08-04

Well I found out why,



Code:
forward [MAX_PLAYER_NAME 1]GetPlayerNameEx(playerid); GetPlayerNameEx(playerid) { new name[MAX_PLAYER_NAME 1]; GetPlayerName(playerid, name, sizeof name); return name; }