$countRes is globally defined in the setup_mysql.php file - function db_simpleSelect(). In general, bb_func_deltopic.php is not a file which handles deletion of the message. bb_func_delmsg.php is the right file.
But I think there is no bug regarding miniBB in that case. We have no reports from other users that claim there is something wrong when deleting a first or any other message. "Internal Server Error" message may come from completely another source, because of improper server configuration when it should recolate to the new page using HEADER function, for example. It also appears very often on IIS servers, so if your server is from Windows series, it could often mean PHP won't work properly when installed on it.