I'm trying to build a message board in PHP/MySQL, and for some strange reason, there is no output sent to the browser after the second of my two include() statements.
The code for index.php:
<?php
$username = $_COOKIE['member'];
//start the session
session_start();
?>
<html>
<head>
<title></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div align="center">
<div id="container">
<!-- Start the table containing the header image and user links -->
<table>
<tr>
<td id="submenu"><?php include("includes/submenu.php"); ?></td>
</tr>
<tr>
<td id="headimage"><img src="images/header.jpg"></td>
</tr>
<tr>
<td id="userlinks"><?php include("includes/userlinks.php"); ?></td>
</tr>
</table>
<!-- End the top table -->
<!-- Start the main table -->
<?php
//connect to the database
require("includes/config.php");
//select all the categories in the database
$get_cat = "SELECT cat_id, cat_name FROM categories";
$get_cat_res = mysql_query($get_cat) or die(mysql_error());
//select all the forums in the database
$get_forums = "SELECT forum_id, forum_name, forum_parent, forum_description FROM forums";
$get_forums_res = mysql_query($get_forums) or die(mysql_error());
//get the number of categories returned (number of rows)
if(mysql_num_rows($get_cat_res) < 1) {//no categories
$display_block = "No categories";
exit;
} else {
$number_cat = mysql_num_rows($get_cat_res);
//"while" loop for the categories
while($cat_info = mysql_fetch_array($get_cat_res)) {
$cat_id = $cat_info['cat_id'];
$cat_name = $cat_info['cat_name'];
//create display
$display_block = "
<div class='tableborder'>
<table border='0' cellspacing='1' cellpadding='4'>
<tr>
<td class='row1' align='left'>$cat_name</td>
</tr>
";
//get all the forums that belong to that certain category
$get_forums = "SELECT forum_id, forum_name, forum_parent, forum_description WHERE forum_parent = $cat_name";
$get_forums_res = mysql_query($get_forums) or die(mysql_error());
//"while" loop for the forums
//create the display string
$display_block .= "
<tr>
<th class='row2'>Marker</th>
<th class='row2'>Forum Name</th>
<th class='row2'>Number of Posts</th>
<th class='row2'>Last Post</th>
</tr>";
while($forum_info = mysql_fetch_array($get_forums_res)) {
$forum_id = $forum_info['forum_id'];
$forum_name = $forum_info['forum_name'];
$forum_parent = $forum_info['forum_parent'];
$forum_description = $forum_info['forum_description'];
//get number of posts
$get_num_posts = "SELECT COUNT($post_id) FROM forum_posts WHERE forum_id = $forum_id";
$get_num_posts_res = mysql_query($get_num_posts) or die(mysql_error());
$num_posts = mysql_result($get_num_posts,0,'count(post_id)');
//get the information about the last post
$get_last_post = "SELECT post_owner, post_create_time FROM forum_posts WHERE forum_id = $forum_id ORDER BY post_id DESC LIMIT 1";
$get_last_post_res = mysql_query($get_last_post) or die(mysql_error());
$last_post_info = mysql_fetch_array($get_last_post_res);
$last_post_owner = $last_post_info['post_owner'];
$last_post_create_time = $last_post_info['post_create_time'];
//add to display
$display_block .= "
<tr>
<td class='row3'><img src='images/forummarker.jpg'></td>
<td class='row3'><a href='topiclist.php?forum_id=$forum_id'>$forum_name</a></td>
<td class='row3'>$num_posts</td>
<td class='row3'>$last_post_owner<br>$last_post_create_time</td>
</tr>
<p></p>
<p></p>";
}
//get the users online (credit for this goes to Daydreamgraphics.com)
//set the time out variable
$timeoutseconds = 420;
//get the time
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
$ip = $_SERVER['REMOTE_ADDR'];
$file = $_SERVER['PHP_SELF'];
$member = $_COOKIE['member'];
//insert into database
if (!empty($member))
{
$qInsert = "INSERT into useronline (timestamp, ip, file, name) VALUES ('$timestamp','$ip','$file','$member') ";
}
else
{
$qInsert = "INSERT into useronline (timestamp, ip, file, name) VALUES ('$timestamp','$ip','$file','') ";
}
$rsInsert = mysql_query($qInsert);
// now delete old timeout records from the database
$delete = mysql_query("DELETE FROM useronline WHERE timestamp<$timeout");
// now optimize the database
$optimize = mysql_query("OPTIMIZE TABLE `useronline` ");
// now for the display, get the records from the database.
// =========================================
// first get the members records
$mresult = mysql_query("SELECT distinct name FROM useronline WHERE file='$file' and name !='' ");
// now get the non-members records
$result = mysql_query("SELECT distinct ip FROM useronline WHERE file='$file' and name ='' ");
@$user = mysql_num_rows($result);
@$muser = mysql_num_rows($mresult);
//create the users online thingy
$display_block .= "
<tr>
<td class='row1'>Users Online</td>
</tr>
<tr>
<td><img src='images/forummarker.jpg'></td>
<td>";
// now get the link to the profile for members online
while ($row = mysql_fetch_array($mresult))
{
extract($row);
$qLink = "select id from membership where name='$name' ";
$rsLink = mysql_query($qLink);
$linkrow = mysql_fetch_array($rsLink);
extract($linkrow);
$display_block .= "<a href=profile.php?id='.$id.'>'.$name.'</a>, ";
}
//close up the row for the users online
$display_block .= "</td></tr>";
//close up the table and the tableborder div
$display_block .= "</table></div>";
}
}
?>
<p>
<?php echo "$display_block"; ?>
</p>
<!-- End the topic display -->
<!-- Start the copyright stuffies -->
<table>
<tr>
<td id="copy"></td>
</tr>
</table>
</div>
</div>
</body>
</html>