mysql_fetch_row causing server crash
#1

Hi all, please review the code below. For some reason, whenever I try to run this function and there is more than one charge to be displayed using mysql_fetch_row, the server just instantly crashes. The server_log.txt says nothing about it and the mysql log says the following:

Код:
[Wed Nov 19 22:05:20 2014] Function: mysql_query executed: "SELECT * FROM `mdc_charges` WHERE `suspect_playerdata_pid`=19 AND `arrest_id` IS NULL;" with result: "0".
[Wed Nov 19 22:05:20 2014] Function: mysql_store_result executed with result: "1"
[Wed Nov 19 22:05:20 2014] Function: mysql_fetch_row executed with result: "2|19|19|Evading a Peace Officer|NULL|2014-11-19 21:46:52".
[Wed Nov 19 22:05:20 2014] Function: mysql_fetch_field executed.
Код:
public mdcDisplayPerson(playerid,playername[]){
	new string[900];
	new Query[900];
	new pid;
	new username[34];
	new charge[60];
	
	format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE `username`='%s'", playername);
    mysql_query(Query);
    mysql_store_result();
	if(mysql_num_rows() == 1){
	    mysql_fetch_int("pid", pid); //Get player db ID
	    mysql_fetch_field("username", username); //Get player name
	    mysql_free_result();
	    format(string, sizeof(string), "Full Name: %s", username);
		
		//Listing charges
		format(Query, sizeof(Query), "SELECT * FROM `mdc_charges` WHERE `suspect_playerdata_pid`=%d AND `arrest_id` IS NULL;", pid);
	    mysql_query(Query);
	    mysql_store_result();
	    new count = 0;
	    while(mysql_fetch_row(Query)){
	        mysql_fetch_field("charge", charge);
            if(count == 0){
                format(string, sizeof(string), "%s\n\nACTIVE CHARGE(s):\n\n %s", string, charge);
			}else{
			    format(string, sizeof(string), "%s\n%s", string, charge);
			}
			count++;
		}
		mysql_free_result();
		
		
		ShowPlayerDialog(playerid, DIALOG_PD_MDC_SEARCHNAME_SUCCESS, DIALOG_STYLE_MSGBOX, "Persons Search", string, "Close", "");
	}else{
		//No user with name
		ShowPlayerDialog(playerid, DIALOG_PD_MDC_SEARCHNAME_ERROR, DIALOG_STYLE_MSGBOX, "Persons Search", "No persons found", "Close", "");
	}
	return 1;
}
Any help would be much appreciated!
Reply


Messages In This Thread
mysql_fetch_row causing server crash - by Jonesy96 - 19.11.2014, 21:31
Re : mysql_fetch_row causing server crash - by Dutheil - 19.11.2014, 21:54
Re: mysql_fetch_row causing server crash - by Jonesy96 - 19.11.2014, 22:37
Re : mysql_fetch_row causing server crash - by Dutheil - 19.11.2014, 22:47
Re: Re : mysql_fetch_row causing server crash - by Jonesy96 - 19.11.2014, 22:55
Re : mysql_fetch_row causing server crash - by Dutheil - 19.11.2014, 23:01
Re: mysql_fetch_row causing server crash - by Jonesy96 - 20.11.2014, 19:11

Forum Jump:


Users browsing this thread: 1 Guest(s)