Monday, 26 August 2013

Notice: Undefined index: tid in C:\wamp\www\forum\view_topic.php on line 33 [on hold]

Notice: Undefined index: tid in C:\wamp\www\forum\view_topic.php on line
33 [on hold]

Hey im trying to create a forum and when i will create a post i get this
error, i have tryed but i cant find error.
Notice: Undefined index: tid in C:\wamp\www\forum\view_topic.php on line 33
Here is the content of view_topic.php:
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>Forum</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="wrapper">
<h2>My First Forum!</h2>
<?php
if (!isset($_SESSION['uid'])) {
echo "<form action='login_parse.php' method='post'>
Username: <input type='text' name='username' />&nbsp;
Password: <input type='password' name='password' />&nbsp;
<input type='submit' name='submit' value='Log In' />
";
} else {
echo "<p>You are logged in as ".$_SESSION['username']." &bull; <a
href='logout_parse.php'>Logout</a>";
}
?>
<hr />
<?php
include_once("connect.php");
$cid = $_GET['cid'];
$tid = $_GET['tid'];
$sql = "SELECT * FROM topics WHERE category_id='".$cid."' AND
id='".$tid."' LIMIT 1";
$res = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($res) == 1) {
echo "<table width='100%'>";
if ($_SESSION['uid']) { echo "<tr><td colspan='2'><input
type='submit' value='Add Reply' onClick=\"window.location =
'post_reply.php?cid=".$cid."&tid=".$tid."'\" /><hr />"; } else {
echo "<tr><td colsspan='2'<p>Please log in to add your
reply.</p><hr /></td></tr>"; }
while ($row = mysql_fetch_assoc($res)) {
$sql2 = "SELECT * FROM posts WHERE category_id='".$cid."'
AND topic_id='".$tid."'";
$res2 = mysql_query($sql2) or die (mysql_error());
while ($row2 = mysql_fetch_assoc($res2)) {
echo "<tr><td valign='top' style='border: 1px
solid #000000;'><div style='min-height:
125px;'>".$row['topic_title']."<br /> by
".$row2['post_creator']." -
".$row2['post_date']."<hr
/>".$row2['post_content']."</div></td><td
width='200' valign='top' align='center'
style='border: 1px solid #000000;'>User Info
Here</td></tr><tr><td colspan='2'><hr
/></td></tr>";
}
$old_views = $row['topic_views'];
$new_views = $old_views + 1;
$sql3 = "UPDATE topics SET topic_views='".$new_views."'
WHERE category_id='".$cid."' AND id='".$tid."' LIMIT 1";
$res3 = mysql_query($sql3) or die (mysql_error());
echo "</table>" ;
}
} else {
echo "<p>This topic does not exist.</p>";
}
$tid='';
?>
</div>
</div>
</body>
</html>
Possibly related are
create_topic_parse.php: pastebin.com/NfuKb4WQ
create_topic.php
: pastebin.com/9c3cQsWK
Can ennyone see where the error is? Thnx :)

No comments:

Post a Comment