MySQL loading
#5

It gets more tricky right now since crashdetect did not report anything. I've seen similar thing once but was a bug with NULL from the plugin - not sure in which version it was and what version you are using.

Let's begin by debugging it manually to see where it stops:
pawn Код:
new rows, fields;
cache_get_data(rows, fields, mysql);
printf("rows: %i", rows);
pawn Код:
hInfo[i][hID] = cache_get_row_int(i, 0);
printf("hInfo[%i][hID] = %i", i, hInfo[i][hID]);
cache_get_row(i, 2, housetitle);
printf("housetitle: %s", housetitle);
cache_get_row(i, 3, housepw);
printf("housepw: %s", housepw);
           
hInfo[i][hOwner] = cache_get_row_int(i, 1);
printf("hInfo[i][Owner] = %i", hInfo[i][hOwner]);
hInfo[i][hInterior] = cache_get_row_int(i, 10);
printf("hInfo[i][hInterior] = %i", hInfo[i][hInterior]);
and so on, continue the rest (print every line).

---

Something I forgot to mention the previous times is what happens when there are more rows that the size of the hInfo array. In this case, you don't have any run time error as crashdetect did not report anything but we gotta prevent it in case it happens in the future.

pawn Код:
for(new i = 0; i < rows; i++)
{
    if (i == sizeof hInfo)
    {
        printf("House limit (%i) was reached. %i rows returned.", sizeof hInfo, rows);
        break; // stop the loop
    }

    hInfo[i][hID] = cache_get_row_int(i, 0);
    ...
---

The player's name can be selected in the same query you select all the data but let's leave it out for now to fix the issue first. At least use this version:
PHP код:
GetNameFromMySQLID(sqlid)
{
    
// Don't select all the data, just the column for the name. Modify to match your table's structure
  
    
new query[50];
    
mysql_format(mysqlquerysizeof(query), "SELECT Name FROM accounts WHERE ID = %d LIMIT 1"sqlid);  
    new 
Cacheresult mysql_query(mysqlquery);
  
    if (
cache_get_row_count()) cache_get_row(00query);
    else 
query "0";
  
    
cache_delete(result);
    return 
query;

Reply


Messages In This Thread
MySQL loading - by Ahmed21 - 26.07.2016, 18:24
Re: MySQL loading - by Konstantinos - 26.07.2016, 18:36
Re: MySQL loading - by Ahmed21 - 26.07.2016, 18:44
Re: MySQL loading - by Ahmed21 - 26.07.2016, 18:50
Re: MySQL loading - by Konstantinos - 26.07.2016, 19:24
Re: MySQL loading - by PrO.GameR - 26.07.2016, 22:13
Re: MySQL loading - by Ahmed21 - 27.07.2016, 07:17
Re: MySQL loading - by Ahmed21 - 27.07.2016, 09:35
Re: MySQL loading - by Konstantinos - 27.07.2016, 09:40
Re: MySQL loading - by Ahmed21 - 27.07.2016, 09:54

Forum Jump:


Users browsing this thread: 1 Guest(s)