Need help with my script!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
iFlex
Forum Commoner
Posts: 41
Joined: Sat May 30, 2009 3:44 am

Need help with my script!

Post by iFlex »

Hi, I made a script that connects to my database and shows a list of people wo have recently posted in the forums.
I dont know why it wont show the details.... if anyone could help I would appreciate it very much :)

I removed the connection details for obvious reasons.

Code: Select all

<?php
mysql_connect('***', '****', '******');
mysql_select_db("********");
echo("Recent Posts <p />");
$recent = mysql_query("SELECT * FROM phpbb_posts ORDER BY post_time DESC LIMIT 5");
while ($recent_row = mysql_fetch_assoc($recent))
 
{
            // Get data
            $post_id = $recent_row['post_id'];
            $topic_id = $recent_row['topic_id'];
            $forum_id = $recent_row['forum_id'];
            $poster_id = $recent_row['poster_id'];
            $post_time = $recent_row['post_time'];
            
            // Get topic name
            $topic_name = mysql_query("SELECT topic_title FROM phpbb_topics WHERE topic_id='$topic_id'");
            $topic_name = mysql_fetch_assoc($topic_name);
            $topic_name = $topic_name['topic_title'];
            
            
            // Get username
            $username = mysql_query("SELECT username FROM phpbb_users WHERE user_id='$poster_id'");
            $username = mysql_fetch_assoc($username);
            $username = $username['username'];
    
            echo "$username posted in $topic_name";
}
 
?>
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Need help with my script!

Post by omniuni »

Just based on what has tripped me up in the past... check your DB structure to make sure you're asking the DB for the right info! Try fetching the results to an array, and print_r it to see what you're getting back.
Post Reply