Help :/

I am making a forum script and where it shows the replies it shows the reply (its supposed to show the users name beside it) it only shows 1 username for all the replies… (note: some variables in the script I am posting won’t be posted, thats not the error.)
[php]<?php
echo ’

'.badWordFilter($gT->content).'

';?> <?php $getReplies = mysql_query("SELECT * FROM Replies WHERE threadID='".$ThreadID."'"); $gR = mysql_fetch_object($getReplies) ; $gT = mysql_fetch_object($getThread) ; while($row12 = mysql_fetch_object( $getReplies)) { $gUt1 = mysql_query("SELECT * FROM Users WHERE username='".$gR->poster."'") or die(mysql_error()); $fgUt1 = mysql_fetch_object($gUt1); $gT = mysql_fetch_object($getThread) ; echo " "; // echo out the contents of each row into a table echo ''; echo ""; echo ""; }
    // close table>
    echo "</table><br/>";
	?>[/php]
'.badWordFilter($row12->content).'

Anybody… :-[

No one T_T

i will take a look

Well, Designer… First, please use a subject that pertains to your post. It allows a lot more members to zone in on the topics they have experience with. Yours would be a subject something like, “having trouble with some DB items not showing”, or “Why does only one user display from database”, something better than “:/”…

Now, I put your code into my DW and found the formatting a little hard to follow. After reformatting it into “my” version, I only found a couple of errors. First, one of your vertical alignment’s were spelled wrong. valing not valign. Minor! Also, your code uses two “mysql_fetch” operations for each use. This is not very good as it would double your database accesses and basically waste time. This is not an issue if you are the only one using the database, but, if many users access the database, it would cause wasted overhead.

Next, I reformatted the listing so that I could see the starting and ending tags. I indented each set of tags with two spaces. This is “my” way of coding. It makes it very easy to see where tags are missing and places the HTML back into it’s normal format. As you can see in my version, you are missing one tag (anchor) and one tag. Both of these are missing in the second table. The first table appears okay.

Back to the “mysql_fetch” operations, you use this line, " $gT = mysql_fetch_object($getThread) ;" and the variable $gT is never used. And, then, a few lines later you use the same line again, but neither times is the “$getThread” variable ever set to any value. So, these fetch’s are not valid.

You should fix the missing anchor or remove it and the missing tbody tag or remove it and rethink your fetching codes.

Hope all of this helps. If not, ask further questions.

Reformatted version to help:
[php]

<?php echo badWordFilter($gT->content); ?>

<?php $getReplies = mysql_query("SELECT * FROM Replies WHERE threadID='".$ThreadID."'"); $gR = mysql_fetch_object($getReplies) ; $gT = mysql_fetch_object($getThread) ; while($row12 = mysql_fetch_object( $getReplies)) { $gUt1 = mysql_query("SELECT * FROM Users WHERE username='".$gR->poster."'") or die(mysql_error()); $fgUt1 = mysql_fetch_object($gUt1); $gT = mysql_fetch_object($getThread) ; ?> // echo out the contents of each row into a table //****** ends, but never started... ****** <?php } ?> // close table>
<?php echo badWordFilter($row12->content); ?>
//****** ends, but never started... ******

[/php]

Erniex i was doing just that, i was formatting it so i that i could read the codes.

but you already did hah

Sorry, Wilson, I didn’t look at your date/time, or I would have let you at it… LOL…

Some of his errors just jumped out at me, so the reformatting was needed… Much easier to read and see errors reformatted with indents. Oh, and just for both of you, there is a notepad replacement called “Notepad++” which actually draws a line down the page so this type of formatting will show the errors easier. I wish my DreamWeaver had that line option! It would make it even easier!

Well, see you both in the bitstream… (That’s really all this is, LOL…)

@ErnieAlex
Here is the problem: http://troll.ws/i/Ow7G4N.png
I red your whole post and I did rethink some of it and I deleted the unnecessary anchors and stuff. Why does it always show the username aboves username on a different post is my question. It should be individually selecting a different username for each reply. I don’t understand how to fix that.

Well, I think it is in your query. It is a bit mixed up. Can you repost what you have now so we can be up to date with your changes and I will take a peek at it for you… Thanks…

I fixed all errors, it resulted so only the thread posted gets to show their profile picture. Thanks for your help.
-designer

the big major fix was what Erniex did to your code at first lol

Sponsor our Newsletter | Privacy Policy | Terms of Service