-1

I keep getting the error "Resource id #26" in PHP:

$R = mysql_query("SELECT * FROM Replies WHERE tid='$gS->ID' ORDER BY ID DESC LIMIT     1"); 
?>

    <tr style="<? echo "$scss"; ?>">
    <td width="560" class="thread" colspan="4" height="70" style="" border-left: 1px solid gainsboro;text-align: center;"><center><a href="./Post.php?id="><? echo "$gS->Title";     ?></center></a>
    <td width="100" align="center" class="thread" style="text-align: center;" valign="middle"><? echo "$R"; ?></td>
    <td width="100" align="center" class="thread" valign="middle"></td>
    <td width="200" class="thread" style="border-right: 1px solid gainsboro;">by <? echo "$LastReply"; ?> <br>January, 1st, 2000 - 2:00am</td>
    </tr>
</table>
Tim Dearborn
  • 1,178
  • 7
  • 18
  • [`mysql_query`](http://php.net/mysql_query) doesn't return any values. You still need to `_fetch_xy()` them. – mario Dec 21 '13 at 02:44
  • You're echoing out your recordset. You'll probably want to `mysql_fetch_array()` or somesuch. – andrewsi Dec 21 '13 at 02:44

1 Answers1

1

You will need fetch the query result like this

$R = mysql_query("SELECT * FROM Replies WHERE tid='$gS->ID' ORDER BY ID DESC LIMIT     1"); 

since $R is just one result you don't need to use a while. use mysql_fetch_assoc()

 $row=  mysql_fetch_assoc($R);

to print use

<?php echo $row['FieldName'];?>

Try to update to mysqli or PDO

Why shouldn't I use mysql_* functions in PHP?

Community
  • 1
  • 1
Emilio Gort
  • 3,475
  • 3
  • 29
  • 44