Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 The one you gave me? I replaced the original board.php code with that for the testing purposes. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Put it on page all by itself. The last code post. Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 What part? The code you provided or the last piece of mine? 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"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid and here they are:<br /><br /><br />"; 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?? ?> 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 and here they are:" Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 oops. else {echo $forumid."<br />";} 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 and here they are:" again even with the edition of echoing the variable. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Just remembered that TEXT/BLOB columns can't have default values. NULL would be the correct setting but, that shouldn't affect what we're doing. Change it. 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 and here they are:" Yeah still the same using NULL. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Post the value of one of the text fields. Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 That is the only text field i have in the db. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 You have 4 entries according to num_rows. Go to your DB (phpMyAdmin) and copy the value of one of the entries...post it also how many tables do you have with a column name forumid? Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Sorry, thought you wanted to see another text row. Not to sure how to get that from inside the db, never had to do it before. How do i? EDIT: Only 1 column name forumid. I have another table with a column called forum_id though, that table is used to create the boards through the admin panel, the id on that is used in the url to access it. e.g. board.php?id=3 Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Then I am pretty sure forumid is empty. The problem must be on post. On your post page... change: $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"); To: $insertpost=mysql_query("INSERT INTO post_reply(author,title,post,forumid,showtime,realtime,lastposter) values('$name','$subject','$yourpost','$forumid','$displaytime','$thedate','$name')"; if (!$insertpost){die(mysql_error());} Try this. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Now I know it's empty. You are inserting blank values int the row forumid... $forumid = $_GET['id']; // THIS MIGHT APPLY TO SOMETHING ELSE BUT NOT ON SUBMIT if(isset($_POST['submit'])) { $forumid=$_POST['forumid']; // YOUR VAR WAS EMPTY $name=$_POST['name']; $yourpost=$_POST['yourpost']; $subject=$_POST['subject']; You have 4 empty rows. Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 "Parse error: syntax error, unexpected ';' " That is the one at the end of the mysql query. If i remove it i get: "Parse error: syntax error, unexpected T_IF" ------- Added in the blank variable bit you mentioned and used the original post page. Still now threads showing though. EDIT: $forumid = $_GET['id']; // THIS MIGHT APPLY TO SOMETHING ELSE BUT NOT ON SUBMIT That is used to grab the ID from the url. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 here is the right code $insertpost=mysql_query(" INSERT INTO post_reply(author,title,post,forumid,showtime,realtime,lastposter) values('$name','$subject','$yourpost','$forumid','$displaytime','$thedate','$name') "); if (!$insertpost){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 No errors with that this time. Problem now is that the posts still aren't showing on the boards.php page. Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 $forumid=$_POST['forumid']; // TAKE IT OUT Stupid mistake on my part put this on the test page: <?php include "config.php"; $TEST=mysql_query("SELECT yourpost FROM post_reply"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid and here they are:<br /><br /><br />"; WHILE($row=mysql_fetch_array($TEST)){ $yourpost=$row['yourpost']; echo $yourpost."<br />"; } // CLOSE YOUR CONNECTION?? ?> Why is your forumid a text field? I imagine (since you can't get to phpAdmin) that $yourpost is a text field Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 I assumed it would be the easiest mysql row to use, which is why i asked earlier if it was the correct one. Now i get: "Unknown column 'yourpost' in 'field list'" I have no row called yourpost, the row for that is post, it is mediumtext. EDIT: i know that, that row have data because if i remove or the id stuff and don't try to fetch it with the id, all the posts show up, just they show up in all the forums as well as the one it was posted in. 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 post FROM post_reply"); if (!$TEST){die(mysql_error());} $num_rows = mysql_num_rows($TEST); echo "I have $num_rows in the row forumid and here they are:<br /><br /><br />"; WHILE($row=mysql_fetch_array($TEST)){ $post=$row['post']; echo $post."<br />"; } // CLOSE YOUR CONNECTION?? ?> Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Fetched each test post i have made. I have 6 in the row forumid and here they are: This better work now. Ok almost got this working. Still not working Getting on my nerves Should work now this better work now Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Now try this: $TEST=mysql_query("SELECT post FROM post_reply WHERE parentid='0'"); Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 6, 2009 Author Share Posted April 6, 2009 Exact same result Quote Link to comment Share on other sites More sharing options...
phpretard Posted April 6, 2009 Share Posted April 6, 2009 Then this: $forumid="what ever you are expecting it to be"; $TEST=mysql_query("SELECT post FROM post_reply WHERE parentid='0' AND forumid='$forumid' "); 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.