hi guys working on a little basic forum for collage but i keep getting this error kinda driving me crazy i know its something small but i cant spot it. any help would be great
Notice: Undefined index: topic_id in /users/2014/daf1/public_html/cs1109/lab18/showit.php on line 14
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /users/2014/daf1/public_html/cs1109/lab18/showit.php on line 23
<?php
require_once( 'output_functions.php' );
require_once( 'validation_functions.php' );
require_once( 'database_functions.php' );
$dbconnection = connect_to_database( 'localhost', 'daf1', 'PASSCODE', '2013?daf1' );
output_header( 'reveiwers nation', 'rr.css' );
$verify_topic = "SELECT topic_title FROM forum_topics WHERE topic_id = '".$_GET["topic_id"]."'";
$dbinsert_result = mysql_query($verify_topic);
if ( ! $dbinsert_result )
{
output_problem_page();
mysql_close( $dbconnection );
die();
}
if (mysql_num_rows($verify_topic) < 1) {
//this topic does not exist
$display_block = "<p><em>You have selected an invalid topic.<br/>
Please <a href=\"topiclist.php\">try again</a>.</em></p>";
} else {
//get the topic title
while ($topic_info = mysql_fetch_array($verify_topic_res)) {
$topic_title = $topic_info['topic_title'];
}
//gather the posts
$get_posts = "SELECT post_id, post_text, DATE_FORMAT(post_create_time, '%b %e %Y at %r') AS fmt_post_create_time, post_owner FROM forum_posts WHERE topic_id = '".$_GET["topic_id"]."' ORDER BY post_create_time ASC";
$dbinsert_result = mysql_query($dbconnection, $get_posts);
if ( ! $dbinsert_result )
{
output_problem_page();
mysql_close( $dbconnection );
die();
}
//create the display string
$display_block = "
<p>Showing posts for the <strong>".$topic_title."</strong> topic:</p>
<table>
<tr>
<th>AUTHOR</th>
<th>POST</th>
</tr>";
while ($posts_info = mysql_fetch_array($get_posts)) {
$post_id = $posts_info['post_id'];
$post_text = $posts_info['post_text'];
$post_create_time = $posts_info['fmt_post_create_time'];
$post_owner = $posts_info['post_owner'];
//add to display
$display_block .= "
<tr>
<td>".$post_owner."<br/>[".$post_create_time."]</td>
<td>".$post_text."<br/><br/>
<a href=\"replytopost.php?post_id=".$post_id."\"><strong>REPLY TO POST</strong></a></td>
</tr>";
}
//free results
mysql_free_result($get_posts);
mysql_free_result($verify_topic);
//close connection to MySQL
mysql_close($dbconnection);
//close up the table
$display_block .= "</table>";
}
?>