Jump to content


Photo

Resource id


  • This topic is locked This topic is locked
1 reply to this topic

#1 Anth

Anth
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 04 November 2005 - 12:30 PM

I posted this on PHP help too, not sure where it should go. At second thoughts it probobly suits MySQL better...

When I use the following code it doesn't error, but instead brings back something that I don't udnerstand.

The code is meant to pull the first post of each topic located in the news board of my phpBB forum.

phpBB uses 2 tables to store its posts. I made this code originally to pull code of SMF forums, and it worked, but SMF only used one table.

$result = mysql_query("SELECT Distinct post_id FROM phpbb_posts where forum_id='1' order by post_id desc")
or die(mysql_error());

echo "<table boarder='0'>";
echo "<tr><th>Subject</th><th>Message</th></tr>";

while($row = mysql_fetch_array($result)) {

$result1 = mysql_query("Select * from phpbb_posts_text where post_id=".$result." order by post_id asc limit 1")
or die(mysql_error());

while($row = mysql_fetch_array( $result1 )) {

echo "<tr><td>";

echo $row['post_subject'];

echo "</td><td>";

echo $row['post_text'];

echo "</td></tr>";

}

}

echo "</table>";
echo $result1;

I put $result1 at the end to see what it returns, it should return nubers only, sinse only numbers exist in that table. However it replies with 'Resource id#4'.

It currently does reveal the newest post of the newest topic twice in the table, then stops.

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 04 November 2005 - 02:26 PM

It is against the Board's Guidelines to create multiple topics dealing with the same issue.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users