12.12.2009, 15:43
Hi, I got a big problem that I can't fix for HOURS.
here's the buggy function, actually totalannonce is supposed to be 10 but after the line "mysql_fetch_field_row(Field,"text");" it magically sets itself to 101 for no appearent reason...
Here are server logs:
here is a screen of the DB:
This is really annoying, so if anyone could help me... Thanks
here's the buggy function, actually totalannonce is supposed to be 10 but after the line "mysql_fetch_field_row(Field,"text");" it magically sets itself to 101 for no appearent reason...
pawn Code:
#define MAX_ANNOUNCEMENTS 10
enum rInfo
{
rName[30],
rText[128],
rContact[20],
rBusy
}new Recuiting[MAX_ANNOUNCEMENTS+1][rInfo];
stock LoadSQLRecuiting()
{
new totalannonce;
new Field[64];
new Data[256];
new sql[80];
format(sql, sizeof(sql), "SELECT COUNT(*) FROM annonces");
mysql_query(sql);
mysql_store_result();
mysql_fetch_row(Data);
totalannonce = strval(Data);
mysql_free_result();
for (new idx=1; idx<=totalannonce; idx++)
{
format(sql, sizeof(sql), "SELECT * FROM annonces WHERE id=%d", idx);
mysql_query(sql);
mysql_store_result();
if (mysql_num_rows() > 0)
{
mysql_fetch_row(Data);
mysql_fetch_field_row(Field,"name");
printf("%s, %d, %d", Field, totalannonce, idx);
strmid(Recuiting[idx][rName],Field,0,strlen(Field),50);
mysql_fetch_field_row(Field,"text");
printf("%s, %d", Field, totalannonce);
strmid(Recuiting[idx][rText],Field,0,strlen(Field),128);
mysql_fetch_field_row(Field,"contact");
printf("%s, %d", Field, totalannonce);
strmid(Recuiting[idx][rContact],Field,0,strlen(Field),20);
mysql_fetch_field_row(Field,"busy");
Recuiting[idx][rBusy] = strval(Field);
}
mysql_free_result();
}
printf("%d recuiting announcements loaded from DB.", totalannonce);
return 1;
}
Quote:
[17:35:14][17:35:14] Sweeper, 10, 1 [17:35:14] Vous conduisez une balayeuse а travers Los Santos afin de nettoyer les rues, 101 [17:35:14] ((/sweeper)), 101 [17:35:14] Aucun, 101, 2 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 3 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 4 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 5 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 6 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 7 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 8 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 9 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101, 10 [17:35:14] Aucun, 101 [17:35:14] Aucun, 101 [17:35:14] 101 recuiting announcements loaded from DB. |
This is really annoying, so if anyone could help me... Thanks