Unexplained server crash when running mysql_query
#1

Hello.

I am logging kills to db. after running format() Query looks like this:
Код:
NSERT INTO phpbb_score VALUES (NULL, '1', '2', '1', CURRENT_TIMESTAMP, '255', '1.2.3.4', '4.3.2.1')
Now the unexplained phenomena: If I remove DebugMsg(playerid,0xFFFFFFFF,Query); this server crashes instantly after executing mysql_query(Query,-1,-1,hForum);. But when I have that DebugMsg there It wont crash. And all It does is that it sends message to client when client is admin. Now what is really interesting is that in windows version I don't have that problem.


pawn Код:
public QueryKill(playerid,killerid,reason){
    new Query[200],player_ip[16],killer_ip[16];
    format(player_ip,sizeof(player_ip),"%s",PlayerInfo[playerid][plIP]);
    killer_ip = "None";
    new tmpkillerid = INVALID_PLAYER_ID;
    if(INVALID_PLAYER_ID != killerid){
        format(killer_ip,sizeof(killer_ip),"%s",PlayerInfo[killerid][plIP]);
        tmpkillerid = PlayerInfo[killerid][plID];
    }
    format(Query,sizeof(Query),"INSERT INTO phpbb_score VALUES (NULL, '%d', '%d', '%d', CURRENT_TIMESTAMP, '%d', '%s', '%s')",PlayerInfo[playerid][plID],tmpkillerid,KILL_SCORE,reason,player_ip, killer_ip);

    DebugMsg(playerid,0xFFFFFFFF,Query);
    mysql_query(Query,-1,-1,hForum);
    mysql_free_result(hForum);
}
Here's my DebugMsg
Код:
public DebugMsg(playerid,color,msg[])
{
	if (playerid == -1){
		if (DevMode){
			SendClientMessageToAll(color,msg);
		}
	}else{
		if(PlayerInfo[playerid][plAdmin] || DevMode){
			SendClientMessage(playerid,color,msg);
		}
	}
}
Could anyone explain why calling this simple function helps me to avoid crash? Why it doesn't crash in windows version?
Ant just 1 more funny fact: If I remove myself from admins calling DebugMsg before mysql_query doesn't save server from crashing.
Reply
#2

INSERT INTO phpbb_score VALUES (NULL, '%d', '%d', '%d', CURRENT_TIMESTAMP, '%d', '%s', '%s')

Should be:

INSERT INTO phpbb_score (FIELD_NAME1, FIELD_NAME2, FIELD_NAME3, FIELD_NAME4, ETC) VALUES (NULL, '%d', '%d', '%d', CURRENT_TIMESTAMP, '%d', '%s', '%s')
Reply
#3

Quote:
Originally Posted by Pizzy
Посмотреть сообщение
INSERT INTO phpbb_score VALUES (NULL, '%d', '%d', '%d', CURRENT_TIMESTAMP, '%d', '%s', '%s')

Should be:

INSERT INTO phpbb_score (FIELD_NAME1, FIELD_NAME2, FIELD_NAME3, FIELD_NAME4, ETC) VALUES (NULL, '%d', '%d', '%d', CURRENT_TIMESTAMP, '%d', '%s', '%s')
Both should work. Also, he said it works if he has DebugMsg function in, so I don't think that the problem is in the query.
Reply
#4

Ok that's strange. At first it looked like adding return to where I set player health 0 helped but then it got random again.

and it didnt pass mysql_free_result... Just wondering if mysql_free_result with nothing to free will crash.

Edit: It was caused mysql_free_result when there was nothing to free. Solution: call this only when you have used SELECT.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)