<?php

require("config.php");

if(isset($_GET['id']) == TRUE) {
if(is_numeric($_GET['id']) == FALSE) {
$error = 1;
}

if($error == 1) {
header("Location: " . $config_basedir);
}
else {
$validtopic = $_GET['id'];
}
}
else {
header("Location: " . $config_basedir);
}

require("header.php");

$topicsql = "SELECT topics.subject, topics.forum_id, forums.name FROM topics, forums WHERE topics.forum_id = forums.id AND topics.id = " . $validtopic . ";";
$topicresult = mysql_query($topicsql);
$topicrow = mysql_fetch_assoc($topicresult);

echo "<h2>" . $topicrow['subject'] . "</h2>";
echo "<a href='index.php'>". $config_forumsname . " forums</a> -> <a href='viewforum.php?id=" . $topicrow['forum_id'] . "'>" . $topicrow['name'] . "</a><br /><br />";

$threadsql = "SELECT messages.subject, messages.body, messages.date, users.username FROM messages, users WHERE messages.user_id = users.id AND messages.topic_id = " . $validtopic . " ORDER BY messages.date;";
$threadresult = mysql_query($threadsql);

echo "<table>";

while($threadrow = mysql_fetch_assoc($threadresult))
{
echo "<tr><td><strong>Posted by <i>" . $threadrow['username'] . "</i> on " . date("D jS F Y g.iA", strtotime($threadrow['date'])) . " - <i>" . $threadrow['subject'] . "</i></strong></td></tr>";
echo "<tr><td>" . $threadrow['body'] . "</td></tr>";
echo "<tr></tr>";
}

echo "<tr><td>[<a href='reply.php?id=" . $validtopic . "'>reply</a>]</td></tr>";
echo "</table>";

require("footer.php");

?>

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/harlow/public_html/forums/viewmessages.php on line 35

That's the warning and my code, I've looked over and over and can't find the problem. I'm relatively new to PHP, so I may be overlooking something.

Could anyone give me some pointers?
Thank you!

Read the FAQ that is right above your post on the PHP forum

I already read it, but it didn't really help me.

I already read it, but it didn't really help me.

Not true, read it again. It answers your question exactly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.