Announcement

Collapse
No announcement yet.

Resource id help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resource id help

    Code:
    $game1=safe_query("SELECT * FROM ".PREFIX."user_gameacc WHERE userID='$id' ORDER BY type");
    if(mysql_num_rows($game1)) {
        $n=1;
    	while($db=mysql_fetch_array($game1)) {
            $game2 = safe_query("SELECT * FROM ".PREFIX."gameacc WHERE gameaccID = '".$db['type']."'");
            $dr = mysql_fetch_array($game2);
    		$n%2 ? $bgcolor=BG_1 : $bgcolor=BG_2;
    
    
    		$game2.='<tr bgcolor="'.$bgcolor.'"><td>
    				<table width="100%" cellpadding="1" cellspacing="2">
                                <tr><td width="30%"><b>'.$dr[type].'</b></td><td width="70%">'.$db[value].'</td></tr>
                               </table></td></tr>';
    		$n++;
    	}
    }
    else $game2='<tr>
                       <td colspan="2" bgcolor="'.BG_1.'">n/a</td>
                     </tr>';
    Output = 1 result only, showing resouce id# (value) I know I missed something but can't figure it out.

  • #2
    Good morning


    $game1=safe_query("SELECT * FROM ".PREFIX."user_gameacc WHERE userID='$id' ORDER BY type");
    if(mysql_num_rows($game1)) {
    $n=1;
    while($db=mysql_fetch_array($game1)) {
    $game2 = safe_query("SELECT * FROM ".PREFIX."gameacc WHERE gameaccID = '".$db['type']."'");

    **** SHOULDN'T THIS BE IN A LOOP AS WEL***
    **** while($dr=mysql_fetch_array($game2)) { ****

    $dr = mysql_fetch_array($game2);
    $n%2 ? $bgcolor=BG_1 : $bgcolor=BG_2;


    $game2.='<tr bgcolor="'.$bgcolor.'"><td>
    <table width="100%" cellpadding="1" cellspacing="2">
    <tr><td width="30%"><b>'.$dr[type].'</b></td><td width="70%">'.$db[value].'</td></tr>
    </table></td></tr>';
    $n++;
    **** END SHOULDN'T THIS BE IN A LOOP***


    }
    }
    else $game2='<tr>
    <td colspan="2" bgcolor="'.BG_1.'">n/a</td>
    </tr>'


    Bye

    Ian Smith
    Forums are about debating pleasantly not agreeing.

    Comment


    • #3
      Hi

      $game2 is the problem.

      It is initiated as an sql resource ID within a loop and then reused as a text variable with the "." to append.

      This will cause your resource id error.
      { Yep, I've done it myself... }

      I suggest you change the first occurance to $game3.

      Scottie
      Last edited by scottie2212; 02-02-10, 08:18 AM.

      Comment


      • #4
        That worked, thank you

        Comment

        Working...
        X