I have in database lj_stats a table called lj, there i have 10 rows, eatch row has 7 fields (id, name, distance, maxspeed, prestrafe, strafes, sync).
How can i load those values in next arrays:
new lj_names[10][33];
new lj_distance[10];
new lj_maxspeed[10];
new lj_prestrafe[10];
new lj_strafes[10];
new lj_sync[10];
PHP Code:
public Load_Tops(id) {
new szTemp[512];
new Data[7];
format(szTemp, 511,"SELECT name,distance,maxspeed,prestrafe,strafes,sync FROM lj_stats");
SQL_ThreadQuery(g_SqlTuple, "QueryLoadTops", szTemp, Data, 6);
}
public QueryLoadTops(FailState,Handle:Query,Error[],Errcode,Data[],DataSize) {
if(FailState == TQUERY_CONNECT_FAILED) log_amx("Load - Could not connect to SQL database. [%d] %s", Errcode, Error);
else if(FailState == TQUERY_QUERY_FAILED) log_amx("Load Query failed. [%d] %s", Errcode, Error);
new i=0;
while(SQL_MoreResults(Query)) {
SQL_ReadResult(Query,0,lj_names[i],32);
lj_distance[i] = SQL_ReadResult(Query,1);
lj_maxspeed[i] = SQL_ReadResult(Query,2);
lj_prestrafe[i] = SQL_ReadResult(Query,3);
lj_strafes[i] = SQL_ReadResult(Query,4);
lj_sync[i] = SQL_ReadResult(Query,5);
i++;
SQL_NextRow(Query);
}
SQL_FreeHandle(Query);
return PLUGIN_HANDLED;
}
Is this thing above working?
EDIT : The thing above is not working.
L 12/24/2011 - 15:47:20: [MySQL] Invalid info tuple handle: 0
L 12/24/2011 - 15:47:20: [AMXX] Displaying debug trace (plugin "hns_ljstats_sql.amxx")
L 12/24/2011 - 15:47:20: [AMXX] Run time error 10: native error (native "SQL_ThreadQuery")