I have noticed this is a common error in php
and i tried to search the net and i can not get my answer, I am trying to create a simpe forum and I am getting these errors
Notice: Undefined variable: topics in C:\xampp\htdocs\mysite\Students forum\view_category.php on line 83
Notice: Undefined variable: topic in C:\xampp\htdocs\mysite\Students forum\view_category.php on line 86
and this is the code on line 83
$topics .= "<table width='100%' style='border-collapse: collapse;'>";
and this is the code on line 86
$topic .= "<tr><td colspan='4'><hr /></td></tr>";
and this is my code
if (mysql_num_rows($res2) > 0) {
// Appending table data to the $topics variable for output on the page
$topics .= "<table width='100%' style='border-collapse: collapse;'>";
$topics .= "<tr><td colspan='4'><a href='index.php'>Return To Forum Index</a>".$logged."<hr /></td></tr>";
$topics .= "<tr style='background-color: #dddddd;'><td>Topic Title</td><td width='65' align='center'>Last User</td><td width='65' align='center'>Replies</td><td width='65' align='center'>Views</td></tr>";
$topic .= "<tr><td colspan='4'><hr /></td></tr>";
// Fetching topic data from the database
while ($row = mysql_fetch_assoc($res2)) {
// Assign local variables from the database data
$tid = $row['id'];
$title = $row['topic_title'];
$views = $row['topic_views'];
$date = $row['topic_date'];
$creator = $row['topic_creator'];
// Check to see if the topic has every been replied to
if ($row['topic_last_user'] == "") { $last_user = "N/A"; } else { $last_user = getusername($row['topic_last_user']); }
// Append the actual topic data to the $topics variable
$topics .= "<tr><td><a href='view_topic.php?cid=".$cid."&tid=".$tid."'>".$title."</a><br /><span class='post_info'>Posted by: ".getusername($creator)." on ".convertdate($date)."</span></td><td align='center'>".$last_user."</td><td align='center'>".topic_replies($cid, $tid)."</td><td align='center'>".$views."</td></tr>";
$topics .= "<tr><td colspan='4'><hr /></td></tr>";
}
$topics .= "</table>";
// Displaying the $topics variable on the page
echo $topics;
}