19.11.2014, 21:31
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:
Any help would be much appreciated!
Код:
[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; }