MySQL problem
#1

We have created a system and I have a little problem when extracting the name of the player database.
I do not know how well I understand but so idea:

PHP код:
mysql_format(SQLszQuerysizeof(szQuery), "SELECT * FROM `aplicatii`");
result mysql_query(SQLszQuery);
for(new 
icache_get_row_count (); != j; ++i) {
    
cache_get_field_content(i"Userid",szResult); userid strval(szResult);
    
cache_get_field_content(i"Date"szResult); format(date256szResult);
    
printf("%d | %s"useriddate);
    
format(szDialogsizeof(szDialog), "%s\t%s\n"GetNameFromDB(userid), date);
    
strcat(szDialog2szDialog);
    
Selected[playerid][x] = userid;
    
x++;
}
cache_delete(result);
    
stock GetNameFromDB(userid) {
    new 
szQuery[256], Cacheresult;
    
mysql_format(SQLszQuerysizeof(szQuery), "SELECT * FROM `users` WHERE `id`='%d'"userid);
    
result mysql_query(SQLszQuery);
    new 
szResult[256], szName[256];
    
format(szName256"Null");
    for(new 
icache_get_row_count (); ji++)
    {
         
cache_get_field_content(i"username"szResult); format(szName256szResult);
    }
    
cache_delete(result);
    
printf("%s"szName);
    return 
szName;

Debug:
PHP код:
With GetNameFromDB(userid):
[
12:35:061
[12:35:06Null
[12:35:061
[12:35:06Null
[12:35:061
[12:35:06Null
[12:35:061
Without
:
[
12:12:151
[12:12:152
[12:12:153
[12:12:15
Database:
I hope you understand.
Reply
#2

no one knows?
Reply
#3

what is exactly your problem?
Reply
#4

Quote:
Originally Posted by Sreyas
Посмотреть сообщение
what is exactly your problem?
If using the 'GetNameFromDB' everywhere looks the same, view and debug (1, 1, 1, 1) if you do not use, looks correct database (1,2,3,4)
Reply
#5

WHAT IS PROBLEM ?
Reply
#6

Why don't you just join the two tables to get the player's name? Moreover consider using threaded queries:
pawn Код:
mysql_tquery(SQL, "SELECT a.Userid,IFNULL(u.username,\"\"),Date FROM aplicatii a LEFT JOIN users u ON u.id=a.Userid;", "OnAplicatiiLoadForPlayer", "i", playerid);
PHP код:
forward OnAplicatiiLoadForPlayer(playerid);
public 
OnAplicatiiLoadForPlayer(playerid)
{
    new
        
tmp_userid,
        
tmp_date[32]; // change accordingly, 256 is way too much
  
    
szDialog2[0] = EOS// reset the string, we don't want any text previously stored
    
for (new icache_get_row_count(); != ji++)
    {
        
// rowid 0 = Userid | rowid 1 = username | rowid 2 = Date
        
tmp_userid cache_get_row_int(i0);
        
cache_get_row(i1szDialog); 
        
cache_get_row(i2tmp_date);
        
format(szDialogsizeof szDialog"%s\t%s\n"szDialogtmp_date);
        
strcat(szDialog2szDialog); 
        
Selected[playerid][i] = tmp_userid
    }

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)