Alienware Posted October 20, 2008 Share Posted October 20, 2008 Here is the code for my forum on my game site.. When i try to view a topic i created as a test forum it just comes up with- Unknown column 'topicid' in 'where clause' If anyone has any idea why please let me know. <?php require("connections/db.php"); require("connections/require.php"); require("connections/replace.php"); echo ("<link rel=\"stylesheet\" href=\"connections/style.css\" type=\"text/css\">"); $chk = mysql_query("SELECT * FROM `staff` WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); $numm = mysql_numrows($chk); $query = mysql_query("SELECT * FROM `players` WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); $array = mysql_fetch_array($query); $family = $array['family']; $q = mysql_query("SELECT * FROM `family` WHERE `name` = '$family' LIMIT 1")or die(mysql_error()); $a = mysql_fetch_array($q); $boss = $a['boss']; $rhm = $a['rhm']; $lhm = $a['lhm']; $loc = $a['location']; $forum = $_GET['forum']; $forum_look = $_GET['forum_look']; $forum_count = 15; $index = 0; if ($forum != "main" && $forum != "family" && $forum != $loc && $numm == 0){ $error = "This is not your family forum."; error($error); exit; } if ($forum != "main" && $forum != "family" && $numm == 1){ $st = mysql_query("SELECT `name` , `location` FROM `family`")or die(mysql_error()); while ($sta = mysql_fetch_array($st)){ $what = $sta[0]; $where = $sta[1]; print ("<center><a href=\"forum.php?forum=".$where."\" target=\"main\">View <b>".$what."'s</b> family forum.</center></a>"); } } if (! isset($forum_look) ) { $forum_look = 0; } $qry = mysql_query("SELECT * FROM `entertopics` WHERE `forum` = '$forum' AND `s` = '1' ORDER BY `id` ASC LIMIT $forum_look , $forum_count")or die(mysql_error()); $query = mysql_query("SELECT * FROM `entertopics` WHERE `forum` = '$forum' AND `s` = '0' ORDER BY `lastreply` DESC LIMIT $forum_look , $forum_count")or die(mysql_error()); $num1 = mysql_numrows($qry); $num2 = mysql_numrows($query); $num = $num1 + $num2; function index_navigation($index, $count, $num) { $forum = $_GET['forum']; print ("<center>"); if ($index != 0) { print " <a href=\"forum.php?forum=".$forum."&forum_look=" . ($index - $count) . "\">Previous</a> "; } if ($num >= $count) { print " <a href=\"forum.php?forum=".$forum."&forum_look=" . ($index + $count) . "\">Next</a> "; } print ("</center>"); } if ($_GET['del'] && $forum == "main"){ $del = $_GET['del']; if ($numm == 0){ $error = "Access denied."; error($error); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }elseif ($num > 0){ mysql_query("DELETE FROM `entertopics` WHERE `id` = '$del' LIMIT 1")or die(mysql_error()); $upd = "Topic deleted."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }} if ($_GET['del'] && $forum == $loc){ $del = $_GET['del']; if ($boss != $player && $rhm != $player && $lhm != $player){ $error = "Access denied."; error($error); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }elseif ($boss == $player || $rhm == $player || $lhm == $player){ mysql_query("DELETE FROM `entertopics` WHERE `id` = '$del' LIMIT 1")or die(mysql_error()); mysql_query("DELETE FROM `enterforum` WHERE `topicid` = '$del' ORDER BY `id` DESC")or die(mysql_error()); $upd = "Topic deleted."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }} if ($_GET['stick'] && $forum == "main"){ $stick = $_GET['stick']; if ($numm == 0){ $error = "Access denied."; error($error); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }elseif ($numm > 0){ mysql_query("UPDATE `entertopics` SET `s` = '1' WHERE `id` = '$stick' LIMIT 1")or die(mysql_error()); mysql_query("DELETE FROM `enterforum` WHERE `topicid` = '$del' ORDER BY `id` DESC")or die(mysql_error()); $upd = "Topic stickied."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }} if ($_GET['stick'] && $forum == $loc){ $stick = $_GET['stick']; if ($boss != $player && $rhm != $player && $lhm != $player){ $error = "Access denied."; error($error); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }elseif ($boss == $player || $rhm == $player || $lhm == $player){ mysql_query("UPDATE `entertopics` SET `s` = '1' WHERE `id` = '$stick' LIMIT 1")or die(mysql_error()); $upd = "Topic stickied."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }} if ($_GET['topic']){ $topic = $_GET['topic']; if ($topic == "new"){ if (strip_tags($_POST['submit'])){ $name = strip_tags(addslashes($_POST['topic'])); $text = strip_tags(addslashes($_POST['text'])); if (strlen($name) < 3 || strlen($name) > 40){ $error = "Topic name can only be between 3 and 40 characters."; error($error); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }elseif (strlen($name) >= 3 && strlen($name) <= 40){ if (!$text || $text == " "){ $error = "Text field cannot remain null."; error($error); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }elseif ($text && $text != " "){ mysql_query("INSERT INTO `entertopics` ( `id` , `creator` , `topic` , `text` , `forum` , `replys` , `lastreply` , `s` , `l` ) VALUES ( '' , '$player' , '$name' , '$text' , '$forum' , '0' , '' , '0' , '0' )")or die(mysql_error()); $upd = "Topic created."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=forum.php?forum=".$forum."\">"); }}} ?> <form action="" method="post"> <table width="30%" align="center" class="tbl"> <tr><td align="center" class="hdr">Create a new topic</td></tr> <tr><td align="center" class="sub">Title</td></tr> <tr><td align="center" class="tbl"> <? text(topic); ?> </td></tr> <tr><td align="center" class="sub">Text</td></tr> <tr><td align="center" class="tbl"> <textarea name="text" rows="5" cols="35"></textarea> </td></tr> <tr><td align="center" class="tbl"> <? sub(submit,Create); ?> </td></tr> </table> </form> <? }} if ($forum == "main"){ $echo = "Entertainment"; }else{ $echo = "Family"; } ?> <table width="75%" align="center" class="tbl"> <tr><td colspan="3" align="center" class="hdr"> <b><? print $echo; ?> Forum - </b><a href="?topic=new&forum=<? print $forum; ?>">New topic</a> </td></tr> <tr> <td align="left" width="65%" class="sub"> <strong>Topic</strong></td> <td align="left" width="20%" class="sub"> <strong>Creator</strong></td> <td align="center" width="15%" class="sub"><strong>Replys</strong></td> </tr> <? while ($arr = mysql_fetch_array($qry)){ $forum = $_GET['forum']; ?> <tr> <td align="left" width="65%" class="tbl"> <a href="viewtopic.php?id=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><strong>STICKY:</strong> <? print $arr[topic]; ?></a> </td> <td align="left" width="20%" class="tbl"> <a href="../profile.php?player=<? print $arr[creator]; ?>"><? print $arr[creator]; ?></a> </td> <td align="center" width="15%" class="tbl"><? print $arr[replys]; if ($numm > 0 && $forum == "main"){ ?> | <a href="?del=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> <? if ($boss == $player && $forum == $loc){ ?> | <a href="?del=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> <? if ($rhm == $player && $forum == $loc){ ?> | <a href="?del=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> <? if ($lhm == $player && $forum == $loc){ ?> | <a href="?del=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $arr[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> </td></tr> <? } ?> <? while ($array = mysql_fetch_array($query)){ $forum = $_GET['forum']; ?> <tr> <td align="left" width="65%" class="tbl"> <a href="viewtopic.php?id=<? print $array[id]; ?>&forum=<? print $forum; ?>"><? print $array[topic]; ?></a> </td> <td align="left" width="20%" class="tbl"> <a href="../profile.php?player=<? print $array[creator]; ?>"><? print $array[creator]; ?></a> </td> <td align="center" width="15%" class="tbl"><? print $array[replys]; if ($numm > 0 && $forum == "main"){ ?> | <a href="?del=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> <? if ($boss == $player && $forum == $loc){ ?> | <a href="?del=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> <? if ($rhm == $player && $forum == $loc){ ?> | <a href="?del=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> <? if ($lhm == $player && $forum == $loc){ ?> | <a href="?del=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="red"><strong>X</strong></font></a> | <a href="?stick=<? print $array[id]; ?>&forum=<? print $forum; ?>"><font color="blue"><strong>S</strong></font></a> <? } ?> </td></tr> <? } ?> </table><br /><br /> <table align="center" width="18%" class="tbl"> <align='centre'><tr><td align="center" class="hdr">.::Abuse of forum::.</td></tr></align> <tr><td align="left" class="tbl"> <a href="http://www.ny-mobster.net/reporttopic.php" target="main"><font color="red"><center>Report Forum Abuse</center></font></a><br /> </td></tr> </table> <? index_navigation($forum_look, $forum_count, $num); ?> Link to comment https://forums.phpfreaks.com/topic/129326-forum-problem/ Share on other sites More sharing options...
Alienware Posted October 21, 2008 Author Share Posted October 21, 2008 i have been trying for hours but got no further with it Link to comment https://forums.phpfreaks.com/topic/129326-forum-problem/#findComment-670501 Share on other sites More sharing options...
DarkWater Posted October 21, 2008 Share Posted October 21, 2008 Do you have a topicid column in enterforum? >_< Link to comment https://forums.phpfreaks.com/topic/129326-forum-problem/#findComment-670503 Share on other sites More sharing options...
Alienware Posted October 21, 2008 Author Share Posted October 21, 2008 yes, i checked this thinking perhaps i had made a mistake there... but unfortunately not. Link to comment https://forums.phpfreaks.com/topic/129326-forum-problem/#findComment-670506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.