Hi,
The following code is supposed to retrieve some stuffs from my database using AMXX v1.76a:
Code:
// The SQL query retrieve the 15 best players average XP
new szQuery[256];
format(szQuery, 255, "SELECT AVG(`xp`) as `xp_avg` FROM \
(SELECT `xp` FROM `%s` ORDER BY `xp` DESC LIMIT 0, 15) \
AS `best_players`",
g_DBTableName);
new Result:res = dbi_query(sql, szQuery);
// Make sure we have a result
if (res <= RESULT_NONE) {
server_print("%s An error has occurred when retrieving the best \
players XP average.", g_MODclient);
XP_DBI_Error( res, szQuery, 0 );
return PLUGIN_CONTINUE;
}
if(res && dbi_nextrow(res)) {
new szXP[8], iXP, iLevel;
dbi_result(res, "xp_avg", szXP, 7);
iXP = str_to_num( szXP );
// Compute the level corresponding to these XPs
for(new i = 0 ; i <= 10 ; ++i) {
if(iXP >= xplevel[i])
iLevel = i
else
break
}
// Set multiplier values for each level under the (average) best one
new iLevelDiff = 10 - iLevel
while(iLevel >= 0) {
xpmultiplier[iLevel] = multiplierdata[iLevel + iLevelDiff]
iLevel--
}
}
// Free the result set
dbi_free_result(res);
The connection to the DB works, and the query doesn't fail. Most of the time, there is a row result (i.e., when the table isn't empty). The problem is at the last line ; every time it's executed, I've got a message in the error log:
Code:
[MySQL] Invalid DBI result handle 54
[AMXX] Displaying debug trace (plugin "warcraft3FT.amxx")
[AMXX] Run time error 10: native error (native "dbi_free_result")
[AMXX] [0] XP.inl::XP_Set_Multiplier (line 315)
[AMXX] [1] XP.inl::XP_Set (line 179)
[AMXX] [2] war3ft.inl::WAR3_Set_Variables (line 1221)
It's weird, because if the handle was invalid, an almost identical error message should have been written when the
dbi_result function is called ! The only difference between
dbi_free_result and
dbi_result is the way the result handle is given (by reference for the former, by value for the later). However, there're other queries that are made in almost the same way (dbi_query->dbi_nextrow->dbi_result->dbi_free_result) to the same table in the plugin, and no error message is present in the error log related to these other queries, so I really don't understand why I've got this issue
If you can explain me the reason for that error message, please do it, because I'm really tired of that error log pollution

Thanks in advance