mysql_fetch_field_row = 0 for all
#1

hello, i have a problem in my gamemode.

when i take the function "mysql_fetch_field_row" for "PlayerInfo", the result is "0" for all.... i don't know why.

the script:
PHP код:
        format(stringsizeof(string), "SELECT * FROM `users` WHERE username = '%s'"gUsername[playerid]);
        
mysql_query(string);
        
mysql_store_result();
        if(
mysql_num_rows() > 0)
        {
            
mysql_fetch_field_row(field"id"); User[playerid][pSQL] = strval(field);
        }
        
mysql_free_result(); 
so User[playerid][pSQL] = strval(field); = 0 but it is not normal

mysql log:
PHP код:
[11:31:28CMySQLHandler::Query(SELECT FROM `usersWHERE username 'Angela') - Successfully executed.
[
11:31:28] >> mysql_store_resultConnection handle)
[
11:31:28CMySQLHandler::StoreResult() - Result was stored.
[
11:31:28] >> mysql_num_rowsConnection handle)
[
11:31:28CMySQLHandler::NumRows() - Returned 1 row(s)
[
11:31:28] >> mysql_fetch_field_rowConnection handle)
[
11:31:28CMySQLHandler::FetchField("id") - 
[
11:31:28] >> mysql_queryConnection handle
sorry for my bad english, thanks
Reply
#2

You select all the data for that player to retrieve just their ID? You can select only that specified column:
pawn Код:
"SELECT id FROM users WHERE username = '%s'"
and then use:
pawn Код:
User[playerid][pSQL] = mysql_fetch_int();
to retrieve it.

Two suggestions as well, escape strings and update mysql plugin as there is rarely support for such an old version.
Reply
#3

User ID is just an example.

Other example:
PHP код:
if(mysql_num_rows() > 0)
        {
            
mysql_fetch_field_row(field"id"); User[playerid][pSQL] = strval(field);
            
format(stringsizeof(string), "SELECT * FROM `bans` WHERE `userid` = '%d'"User[playerid][pSQL]);
            
mysql_query(string);
            
mysql_store_result();
            if(
mysql_num_rows() > 0)
            {
                new 
adminname[MAX_PLAYER_NAME], datefintimereason[60];
                
mysql_fetch_field_row(field"adminname"); strmid(adminnamefield0strlen(field), MAX_PLAYER_NAME);
                
mysql_fetch_field_row(field"raison"); strmid(reasonfield0strlen(field), sizeof(reason));
                
mysql_fetch_field_row(field"datefin"); datefin strval(field);
[...] 
(ps: the variable "new field[50] is highest)

And for the R33 version, i don't like this version because it's not compatible with Debian Linux and he use too much memory usage compared to the R5/R6 version.
Reply
#4

up ...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)