Mysql Error 2013
#1

Well i am using this code(query is called under onplayerconnect) the error occurs only seldom(rarely). There is no problem with the code, the troublesome part is that it causes server to lose connection with sql which prevents all other sql connections from happening unless the player relogs.

Код:
public OnPlayerBanCheck(playerid)
{
	if(cache_get_row_count() > 0)
	{
		new id;
		while(cache_get_row_count() > id)
		{
	    	new string[128], bname[25], badmin[25], breason[100], btime[10], bdate[10];
   			cache_get_field_content(id, "pBanned", bname);
   			cache_get_field_content(id, "pBannedBy", badmin);
   			cache_get_field_content(id, "pBanReason", breason);
   			cache_get_field_content(id, "pBanTime", btime);
   			cache_get_field_content(id, "pBanDate", bdate);
   			format(string, sizeof(string), "%s(%d), you were banned by %s for %s. Time: %s, %s", GetPlayerNameEx(playerid), playerid, badmin, breason, bdate, btime);
			new query2[500];
			format(query2, sizeof(query2), "UPDATE bans SET pBanEvade=%d WHERE `pBanned` = '%s'", 1, GetPlayerNameEx(playerid));
			mysql_tquery(c_handle, query2, "SendQuery", "");
		   	printf("%s Has Been Blocked From Connecting To The Server.  IP: %s",GetPlayerNameEx(playerid),ReturnPlayerIp(playerid));
			PlayerPlaySound(playerid, 1062, 0.0, 0.0, 0.0);
			KickEx(playerid);
			id++;
		}

	}
	return 1;
}
error

Код:
[11:19:15] [ERROR] CMySQLQuery::Execute[OnPlayerBanCheck] - (error #2013) Lost connection to MySQL server during query
[11:19:15] [DEBUG] CMySQLQuery::Execute[OnPlayerBanCheck] - error will be triggered in OnQueryError
Reply
#2

I feel like you should be doing the query and storing the results at the same place where you're using them. Also I wouldn't call a non-callback function On* - I'd rather call your function "CheckPlayerBan(playerid)" for instance.

In any case, I suggest you use the mysql_ping() function to check that your connection is still alive prior to any SQL operation, and in case it's not, I'd force a reconnection immediately as I need the DB.
Reply
#3

could this be the issue ?

PHP код:
public OnPlayerConnect(playerid)
{
    new 
IP[16], query[200], query2[200], player[24];
    
GetPlayerIp(playeridIP16);
    
GetPlayerIp(playeridPlayerInfo[playerid][IPa], 16);
    
GetPlayerName(playerid,player,sizeof(player));
    
mysql_format(c_handle,querysizeof(query), "SELECT * FROM bans WHERE `pBannedIP` = '%e' OR `pBanned` = '%e'"IPplayer);
    
mysql_tquery(c_handlequery"OnPlayerBanCheck""i"playerid);
    
mysql_format(c_handle,query2sizeof(query2), "SELECT Name, Admin, Reason, unban FROM `tban` WHERE `Name` = '%e' OR `IP` = '%e'"GetPlayerNameEx(playerid),ReturnPlayerIp(playerid));
    
mysql_tquery(c_handlequery2"tbancheck""i"playerid); 
Reply
#4

Why you don't reuse things?
Код:
public OnPlayerConnect(playerid)
{
    new query[117];
    GetPlayerIp(playerid, PlayerInfo[playerid][IPa], 16);
    mysql_format(c_handle,query, sizeof(query), "SELECT * FROM bans WHERE `pBannedIP` = '%e' OR `pBanned` = '%e'", PlayerInfo[playerid][IPa], GetPlayerNameEx(playerid));
    mysql_tquery(c_handle, query, "OnPlayerBanCheck", "i", playerid);

    mysql_format(c_handle,query, sizeof(query), "SELECT Name, Admin, Reason, unban FROM `tban` WHERE `Name` = '%e' OR `IP` = '%e'", GetPlayerNameEx(playerid),ReturnPlayerIp(playerid));
    mysql_tquery(c_handle, query, "tbancheck", "i", playerid);
Remember: Reuse things when you can and don't make string arrays very big... Use Letter Counter to count the characters, so you don't have very long strings...
And I don't see anything that can cause the connection to drop...
Reply
#5

upgraded my mysql plugin lately. Still getting this;

PHP код:
[13:17:361054 Unknown column 'Heller' in 'where clause' OnPlayerBanCheck SELECT FROM `bansWHERE `pBanned` = `Heller` OR `pBannedIP` = `` 
Reply
#6

It means you don't have the column in your database...
Reply
#7

i think i have found the temporary fix. ty u all for your support
Reply
#8

Quote:

WHERE `pBanned` = `Heller`

You used backticks instead of single quotes for the value here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)