SA-MP Forums Archive
MySQL issue. - 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 issue. (/showthread.php?tid=624134)



MySQL issue. - Dayrion - 11.12.2016

Hii'.
Firstly, I asking you if it's a good way to do that :
PHP код:
    ...
    
mysql_pquery(MySQL"SELECT * FROM Tag""OnTagCount""");    // count number of tag saved
    
return 1;
}
PUBLIC:
OnTagCount()
{
    new 
rows;
    
cache_get_row_count(rows);
    for(new 
i=1<= rowsi++)
    {
        
mysql_pquery(MySQL"SELECT * FROM Tag WHERE `SQLIB` = '%i'""OnTagLoading""i"i); // load each of them
    
}
    
printf("- Chargement terminй. %i tag chargй."TagNumber);
}
PUBLIC:
OnTagLoading(tagid)
{
    
cache_get_value_name_int(0"ID"p_Tag[tagid][tID]);
    
cache_get_value_name_int(0"SQLIB"p_Tag[tagid][tSQLIB]);
    
cache_get_value(0"Owner"p_Tag[tagid][tOwner]);
... 
If not, please tell me how I should do that.
Secondly, I've these errors:
Код:
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_float: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')
[16:40:21] [plugins/mysql] cache_get_value_name_int: invalid row index '0' (number of rows: '0')



Re: MySQL issue. - Vince - 11.12.2016

You already have the entire result set at your disposal in OnTagCount so there is absolutely NO need to send any further queries at that point. Everything in OnTagLoading can be placed inside the loop in OnTagCount. Replace row 0 with row i and tagid with i. Also rows start at 0.


Re: MySQL issue. - X337 - 11.12.2016

Why not just:
Код:
    ...
    mysql_pquery(MySQL, "SELECT * FROM Tag", "OnTagCount", "");    // count number of tag saved
    return 1;
}

PUBLIC:OnTagCount()
{
    new rows, x;
    cache_get_row_count(rows);
    for(new i; i < rows; i++) // loop to fetch all rows
    {
        x = i + 1; // x is to be used as p_Tag index, since your code tell that it's from 1. If it's from 0, just use i as index and remove x variable.
        cache_get_value_name_int(i, "ID", p_Tag[x][tID]);
        cache_get_value_name_int(i, "SQLIB", p_Tag[x][tSQLIB]);
        cache_get_value(i, "Owner", p_Tag[x][tOwner]);
    }
    printf("- Chargement terminй. %i tag chargй.", TagNumber);
}



Re: MySQL issue. - Dayrion - 11.12.2016

Lol, I'm so stupid.
Thanks you.