Problem with row/field IDs when using R8 r34
#1

Good day everyone. As I have updated the version of the MySQL plugin, I get some errors when, for example, loading server's data.

The query:

pawn Код:
mysql_function_query(_, "SELECT * FROM `statistics` WHERE `ID` = '1'", true, "OnServerStatisticsLoad", "")
The code:

pawn Код:
sInfo[statsBankMoney] = cache_get_row_int(1, 0);
sInfo[statsServerUp]  = cache_get_row_int(1, 1);
sInfo[statsAccounts]  = cache_get_row_int(1, 2);
sInfo[statsConnects]  = cache_get_row_int(1, 3);
sInfo[statsKills]     = cache_get_row_int(1, 4);
sInfo[statsDeaths]    = cache_get_row_int(1, 5);
Log:



I've tried many ways, for example, using cache_get_field_content, setting row and field IDs to 0, no difference.

Any help?
Reply
#2

If there is only one row, then it'd be 0 not 1 (left side). If there are more rows about each ID, then use a loop and replace 1 with the loop's increaser variable.
Reply
#3

No, there's only one row. I just tried to set it to 0 once again, same result. Invalid row and/or field ID.
Reply
#4

Since there's only one row, it should be 0. The error goes for the field index that it's not valid.

Would you mind to show us the table's structure (of statistics)?
Reply
#5

Here you go;



The ID field value is always 1. I tried to load the statistics something like that:

pawn Код:
SELECT * FROM `statistics`
but it didn't worked out, or I didn't got something.
Reply
#6

Try executing that query through phpMyAdmin and tell us whether it executed successfully or not.

However, I can't seem to find anything wrong (except the row I told you).

It should be:
pawn Код:
sInfo[statsBankMoney] = cache_get_row_int(0, 0);
sInfo[statsServerUp]  = cache_get_row_int(0, 1);
sInfo[statsAccounts]  = cache_get_row_int(0, 2);
sInfo[statsConnects]  = cache_get_row_int(0, 3);
sInfo[statsKills]     = cache_get_row_int(0, 4);
sInfo[statsDeaths]    = cache_get_row_int(0, 5);
By the way, what about ID? If it is always 1, then you actually don't need it and you can use "SELECT * FROM `statistics`".
Reply
#7

I just tried that code and it's the same [I think I've been trying it yesterday too]. What about the ID? Well, as I said in my last post, when I was trying to simply use SELECT * FROM `somewhere`, statistics won't load, or I did something wrong, but I'll try rewritting it later on.

phpmyadmin result:

pawn Код:
MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0008 sec )
Reply
#8

According to phpMyAdmin, there are not rows. I assume when there are not rows, the error about invalid row or field index is shown.

You can use either cache_num_rows or cache_get_data (and get rows) and then check if rows are greater than 0. If so, then load to the variables. Otherwise, do not.
Reply
#9

Okay, I'll try a bit later. Thanks for helping out!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)