Alienware Posted October 26, 2008 Share Posted October 26, 2008 I have a forum that i am trying to get to work, however its really not doing what its supposed to. I have no idea why... perhaps someone might know whats wrong? entertopics.php- <?php require('connections/db.php'); require('connections/require.php'); require("connections/replace.php"); echo ("<link rel=\"stylesheet\" href=\"connections/style.css\" type=\"text/css\">"); $query = mysql_query("SELECT * FROM `players` WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); $arr = mysql_fetch_array($query); $family = $arr['family']; $qu = mysql_query("SELECT * FROM `family` WHERE `name` = '$family' LIMIT 1")or die(mysql_error()); $ar = mysql_fetch_array($qu); $boss = $ar['boss']; $rhm = $ar['rhm']; $lhm = $ar['lhm']; $loc = $ar['location']; $topicid = $_GET['id']; $forum = $_GET['forum']; $forum_look=$_GET['forum_look']; $forum_count = 10; $index = 0; $chk = mysql_query("SELECT * FROM `staff` WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); $numm = mysql_numrows($chk); if ($forum != "main" && $forum != "family" && $forum != $loc && $numm == 0){ $error = "This is not your family forum."; error($error); exit; } if (! isset($forum_look) ) { $forum_look = 0; } $qry = mysql_query("SELECT * FROM `enterreplys` WHERE `topicid` = '$topicid' AND `forum` = '$forum' ORDER BY `id` DESC LIMIT $forum_look , $forum_count")or die(mysql_error()); $num = mysql_numrows($qry); $q = mysql_query("SELECT * FROM `entertopics` WHERE `id` = '$topicid' AND `forum` = '$forum' LIMIT 1")or die(mysql_error()); $a = mysql_fetch_array($q); function index_navigation($index, $count, $num) { $forum = $_GET['forum']; $topicid = $_GET['id']; print ("<center>"); if ($index != 0) { print " <a href=\"entertopics.php?id=".$topicid."&forum=".$forum."&forum_look=" . ($index - $count) . "\">Previous</a> "; } if ($num >= $count) { print " <a href=\"entertopics.php?id=".$topicid."&forum=".$forum."&forum_look=" . ($index + $count) . "\">Next</a> "; } print ("</center>"); } if (strip_tags($_POST['submit'])){ $forum = $_POST['forum']; $reply = $_POST['reply_message']; $reply = strip_tags(addslashes($reply)); mysql_query("INSERT INTO `enterreplys` ( `id` , `poster` , `message` , `forum` , `date` , `topicid` ) VALUES ( '' , '$player' , '$reply' , '$forum' , '$date' , '$a[id]' )")or die(mysql_error()); $upd = "Reply added."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=entertopics.php?id=".$topicid."&forum=".$forum."\">"); $newposts = $arr['forumposts'] + 1; mysql_query("UPDATE `players` SET `forumposts` = '$newposts' WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); $newreps = $a['replys'] + 1; $time = time(); mysql_query("UPDATE `entertopics` SET `replys` = '$newreps' , `lastreply` = '$time' WHERE `id` = '$a[id]' LIMIT 1")or die(mysql_error()); } ?> <table width="75%" align="center" class="tbl" border="1" bordercolor="#FFFFFF"> <tr> <td align="center" class="hdr" colspan="2"><b><? print $a[topic]; ?></b> - <a href="../profile.php?player=<? print $a[creator]; ?>"><? print $a[creator]; ?></a> wrote:</td></tr> <tr><td class="tbl" colspan="2"><br /><? print replace($a[text]); ?><br /><br /></td></tr> <? while($ary = mysql_fetch_array($qry)){ $qr = mysql_query("SELECT * FROM `players` WHERE `playername` = '$ary[poster]' LIMIT 1")or die(mysql_error()); $ar = mysql_fetch_array($qr); ?> <tr><td align="center" width="90%" class="sub"> On <? print $ary[date]; ?> <a href="../profile.php?player=<? print $ary[poster]; ?>"><? print $ary[poster]; ?></a> wrote: </td></tr> <tr> <td class="tbl"><br /><? print replace($ary[message]); ?><br /><br /></td> </tr> <? } ?> </table> <p></p> <form action="" method="post"> <input type="hidden" name="forum" value="<? print $forum; ?>"> <table width="45%" align="center" class="tbl"> <tr><td align="center" class="hdr">Reply</td></tr> <tr><td align="center" class="sub">Message</td></tr> <tr><td align="center" class="tbl"> <textarea name="reply_message" cols="30" rows="3"></textarea> </td></tr> <tr><td align="center" class="sub"></td></tr> <tr><td align="center" class="tbl"> <? sub(submit,"Post Reply"); ?> </td></tr> </table> </form> <br /><center><a href="enterforum.php?forum=<? print $forum; ?>">Back to forum</a></center><br /><br /> <? index_navigation($forum_look, $forum_count, $num); ?> enterforum.php- <?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=\"enterforum.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=\"enterforum.php?forum=".$forum."&forum_look=" . ($index - $count) . "\">Previous</a> "; } if ($num >= $count) { print " <a href=\"enterforum.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 `enterreplys` WHERE `topicid` = '$del' ORDER BY `id` DESC")or die(mysql_error()); $upd = "Topic deleted."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=enterforum.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=enterforum.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 `enterreplys` WHERE `topicid` = '$del' ORDER BY `id` DESC")or die(mysql_error()); $upd = "Topic stickied."; upd($upd); print ("<META HTTP-EQUIV=\"refresh\" content=\"1; url=enterforum.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=enterforum.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=enterforum.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=enterforum.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=enterforum.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=enterforum.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="entertopic.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="entertopic.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); ?> anyone got any ideas? I have checked all the database links, they are all correct, but there is still a problem somewhere. Link to comment https://forums.phpfreaks.com/topic/130182-php-forum-help/ Share on other sites More sharing options...
dezkit Posted October 26, 2008 Share Posted October 26, 2008 It will be helpful if you told us what the problem is? Link to comment https://forums.phpfreaks.com/topic/130182-php-forum-help/#findComment-675088 Share on other sites More sharing options...
Alienware Posted October 26, 2008 Author Share Posted October 26, 2008 It isnt letting players view the topic al all. Link to comment https://forums.phpfreaks.com/topic/130182-php-forum-help/#findComment-675097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.