21.03.2015, 19:28
(
Последний раз редактировалось Sascha; 22.03.2015 в 19:41.
)
Hi,
I'm facing a problem when loading data from a mysql db...
I'm trying to save them in an enum, here's the code
the enum:
here's the string that is printed as "tmp" (only 1 line, as there only is one line in the db)
although the data are saved wrong, if I use this:
it shows 0 as owner whereas it should be 1 and nothing for the name.
where's the mistake on that?
I'm facing a problem when loading data from a mysql db...
I'm trying to save them in an enum, here's the code
pawn Код:
stock Load()
{
new string[100], tmp[300], rows = 0, n = 1;
format(string, sizeof(string), "SELECT * FROM `table` ORDER BY `id` ASC");
mysql_query(string);
mysql_store_result();
while(mysql_fetch_row(tmp, "|"))
{
rows++;
print(tmp);
if(!sscanf(tmp, "p<|>e<is[50]iiii>", MyData[n]))
{
n++;
}
}
mysql_free_result();
Count = n;
return 1;
}
pawn Код:
enum CI
{
compID,
compName[55],
compOwner,
compKind,
compBank,
compActive
}
new MyData[][CI];
Код:
1|This Name|1|1|0|1
pawn Код:
for(new n=1; n<=Count; n++)
{
format(string, sizeof(string), "%d", MyData[n][compOwner]);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, sizeof(string), "%s", MyData[n][compName]);
SendClientMessage(playerid, COLOR_GREY, string);
}
where's the mistake on that?