Ashoar Posted April 6, 2009 Share Posted April 6, 2009 This thread relates to an earlier thread i have made. I have moved forward from where i was in the other thread and now face one last problem. The other thread can be found here: http://www.phpfreaks.com/forums/index.php/topic,246353.0.html So i am making a small forum system. I have made sections for users to post topics in certain boards, which can be made through an administration panel. Each board on the main page has it's own id.. e.g "board.php?id=1" After clicking on a board on the main page the user is then taken to a new page called board.php which off course is followed by the id of that board. My original problem is that if i posted in one board, that same post would then be shown in every other board instead of just the board it was created in. From there i have managed to decipher what board a user is on when they post which then inserts the id of that board into the MYSQL table. My problem now is that i cannot display the threads now. From what i am aware i am using the correct method of fetching the board id from the MYSQL table along with the rest of the post information, but it won't display the thread. Here are the codes. Post.php <?php include "config.php"; $forumid = $_GET['id']; if(isset($_POST['submit'])) { $name=$_POST['name']; $yourpost=$_POST['yourpost']; $subject=$_POST['subject']; if(strlen($name)<1) { print "You did not type in a name."; } else if(strlen($yourpost)<1) { print "You did not type in a post."; } else if(strlen($subject)<1) { print "You did not enter a subject."; } else { $thedate=date("U"); $displaytime=date("F j, Y, g:i a"); $subject=strip_tags($subject); $name=strip_tags($name); $yourpost=strip_tags($yourpost); $insertpost="INSERT INTO post_reply(author,title,post,forumid,showtime,realtime,lastposter) values('$name','$subject','$yourpost','$forumid','$displaytime','$thedate','$name')"; mysql_query($insertpost) or die("Could not insert post"); print "Message posted, go back to <A href='index.php'>Forum</a>."; } } else { print "<form action='post.php' method='post'>"; print "Your name:<br>"; print "<input type='text' name='name' size='20'><br>"; print "Subject:<br>"; print "<input type='text' name='subject' size='20'><br>"; print "Your message:<br>"; print "<textarea name='yourpost' rows='5' cols='40'></textarea><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } print "</td></tr></table>"; ?> Using that code the post will save into the database and come back saying the post was made successfully. This is the database row that the forumid is saved too (just incase i am using it wrong) " forumid text NOT NULL," And this is the board.php <?php <?php include "config.php"; $forumid = $_GET['id']; print "<link rel='stylesheet' href='style.css' type='text/css'>"; print "<A href='post.php?id=$forumid'>New Topic</a><br>"; print "<table class='maintable'>"; print "<tr class='headline'><td width=50%>Topic</td><td width=20%>Author/td><td>Replies</td><td>Last reply</td></tr>"; $info="SELECT * from post_reply where parentid='0' AND forumid="$forumid" ORDER BY lastrepliedto DESC"; $info2=mysql_query($info) or die("Could not get threads"); while($info3=mysql_fetch_array($info2)) { $info3[title]=strip_tags($info3[title]); $info3[author]=strip_tags($info3[author]); print "<tr class='mainrow'><td><A href='message.php?id=$info3[postid]'>$info3[title]</a></td><td>$info3[author</td <td>$info3[numreplies]</td><td>$info3[showtime]<br>Last post by <b>$info3[lastposter]</b></td></tr>"; } print "</table>"; ?> SO what could the problem be? Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 In the post of board page? Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 in all your querys to mysql Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Just replace "or die("Could not get threads");" with it? Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 EDIT: (can't edit posts) That still does not help in displaying the threads. Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted April 6, 2009 Share Posted April 6, 2009 That still does not help in displaying the threads. No, but it should help in diagnosing why it won't display the threads Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Well it just displays a blank page with only my title bar. The posts still don't show under it, nor do any error messages. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 You have 2 <?php tags on board.php Is that a post error? Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 replace: $info="SELECT * from post_reply where parentid='0' AND forumid="$forumid" ORDER BY lastrepliedto DESC"; with: replace: $info="SELECT * from post_reply where parentid='0' AND forumid='$forumid' ORDER BY lastrepliedto DESC"; // ADDED forumid='$forumid' // no double quotes Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 That was my bad adding the code here. There is not 2 tags in the actual code. Again no error message or posts displayed is i replace that. Am i using the correct type of table row to store the id into? forumid text NOT NULL, Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Did you take away the double quotes? Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Sure did Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 print "<tr class='mainrow'><td><A href='message.php?id=$info3[postid]'>$info3[title]</a></td><td>$info3[author</td <td>$info3[numreplies]</td><td>$info3[showtime]<br>Last post by <b>$info3[lastposter]</b></td></tr>"; $info3[author</td // not closed "]" and the </td is not closed ">" should be: $info3[author]</td> Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Fixed. Still not working. Again as i said, is it something to do with the MYSQL row? forumid text NOT NULL, Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Also, if i remove the forum id section from the MYSQL query it does work, but it shows the thread on every board and not just the one it was posted in. $info="SELECT * from post_reply where parentid='0' ORDER BY lastrepliedto DESC"; Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 <?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply WHERE parentid='0' "); WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; echo $forumid; } // CLOSE YOUR CONNECTION?? ?> What does this give you? Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Just a blank <?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply WHERE parentid='0' "); WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; echo $forumid; } // CLOSE YOUR CONNECTION?? ?> What does this give you? Just a blank page. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Does parent id='0'? Is there a value in forumid? as far as NULL or NOT NULL change it back and forth and find out if that's the problem PS. Backup your DB first. Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 The parentid is used for the posts to see if it is a new thread or a reply. Yes there are many values in forumid. I have made numerous test posts in one certain board to see if it works. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 <?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply"); WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; echo $forumid."<br />"; } // CLOSE YOUR CONNECTION?? ?> Try it without the WHERE clause. Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 A blank page again Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 If that gave you a blank page: <?php include "config.php"; $TEST=mysql_query("SELECT forumid FROM post_reply"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid"; WHILE($row=mysql_fetch_array($TEST)){ $forumid=$row['forumid']; if ($num_rows=="0"){ echo" connecting to the wrong DB<br /> AND / OR<br /> connecting to the wrong table<br /> AND / OR<br /> forumid is empty<br /> "; }else {$forumid."<br />";} } // CLOSE YOUR CONNECTION?? ?> This will not give you a blank page. Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 "I have 4 in the row forumid " Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Are you putting this code on a new page? Or trying to include it in the forum? Just tying to narrow down to the problem page Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.