SA-MP Forums Archive
MySQL function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL function (/showthread.php?tid=662470)



MySQL function - Heress - 02.01.2019

Quote:

[16:39:19] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[16:39:19] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[16:39:19] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')
[16:39:19] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0')

Код:
public OnServerInfoLoad()
{
	serverInfo[taxi_darbo_fondas] = cache_get_field_content_int(0, "taxi_darbo_fondas", manomysql);
	serverInfo[mediku_darbo_fondas] = cache_get_field_content_int(0, "mediku_darbo_fondas", manomysql);
	serverInfo[policijos_darbo_fondas] = cache_get_field_content_int(0, "policijos_darbo_fondas", manomysql);
	serverInfo[mafijos_darbo_fondas] = cache_get_field_content_int(0, "mafijos_darbo_fondas", manomysql);
}
Problem is what I dont have playerid and name. This is global server information. What function
instead cache_get_field_content_int i can use?



Re: MySQL function - Calisthenics - 02.01.2019

There are no rows. Use cache_num_rows first to make sure there are rows returned and then use the cache functions.


Re: MySQL function - Heress - 02.01.2019

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
There are no rows. Use cache_num_rows first to make sure there are rows returned and then use the cache functions.
Something like this?

Код:
    new num_rows, num_fields;
    cache_get_data(num_rows, num_fields, manomysql);
    if(num_rows == 1)
Or this?

Quote:

new num_fields,num_rows;
cache_get_data(num_rows,num_fields,manomysql);
if(!num_rows)return 1;
for(new i=0; i<num_rows; i++)
{
//code
}




Re: MySQL function - Heress - 02.01.2019

If someone will have this error do this:

create
Quote:

new num_fields,num_rows;

Then
Quote:

cache_get_data(num_rows,num_fields,manomysql);

Quote:

if(!num_rows)return 1; // return if there isn't um rows

Then loop num_rows
Quote:

for(new i=0; i<num_rows; i++)

And in function use "i"
Quote:

cache_get_field_content_int(i, "info", mysql)



Thanks, problem solved