[help] online.php help please

Newbie Spellweaver
Joined
Dec 1, 2004
Messages
75
Reaction score
0
can someone tell me why this doesnt work? i get no odbc errors but it doesnt show who is online.

Code:
<?php 

   $cnx = odbc_connect("T4C Server", "root", ""); 
   $query = "SELECT * FROM onlineusers ORDER BY PlayerName"; 
   $result = odbc_exec($cnx, $query); 
   $i=1; 
   $sexe="Rien";
   $listingtitle="{Se connecte}";
   $nb_renais="0";
   $tab_sexe = array("<img src='male.gif'></img>","<img src='femelle.gif'></img>"); 
    
   while (odbc_fetch_into($result, $onlineuser)) 
   { 
      $playername = $onlineuser[2];// "PlayerName" 
      
      if ($playername!="") 
      { 
         $query2 = "SELECT * FROM PlayingCharacters WHERE PlayerName='" . $playername . "';"; 
         $result2 = odbc_exec($cnx, $query2); 
          
         if (odbc_fetch_into($result2, $playingcharacter)) 
         {    
            $userid = $playingcharacter[0];         //"UserID" 
            $sexe = $tab_sexe[$playingcharacter[28]];    //"Gender" 
            $listingtitle = $playingcharacter[30];      //"ListingTitle" 
            if ($listingtitle=="") $listingtitle=" "; 
                
            $query3 = "SELECT * FROM Flags WHERE `OwnerID`=" . $userid . " AND `FlagID`=30419"; 
            $result3 = odbc_exec($cnx, $query3); 
            if (odbc_fetch_into($result3, $flags)) 
            { 
                
               $nb_renais=$flags[4];//FlagValue 
            } 
            else 
            { 
               $nb_renais=" "; 
            } 
         } 
         
?> 
                     <tr> 
                        <td><?=$i;?> </td> 
                        <td><?=$playername;?> </td> 
                        <td><?=$sexe;?> </td> 
                        <td><?=$listingtitle;?> </td> 
                        <td><?=$nb_renais;?> </td> 
                     </tr> 
<?php 
   } 
      $i++; 
      
   } 
   odbc_close($cnx); 
    
?>
 
You may not use "select * from" if you use only one column result.
Just select what you need.
Use odbc_fetch_array function.
 
Back