Jump to content

What is wrong here


Ashoar

Recommended Posts

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?

Link to comment
Share on other sites

  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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


Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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>


Link to comment
Share on other sites

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";

Link to comment
Share on other sites


<?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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.