hi guys i hope you missed mei am trying to create a comments feature for my website that will allow registered users to leave comments on certain pages, right now i am in the stage of getting everything to show up when a user visits that page. The problem i am having is when i go to the page there is nothing displayed (other than the login feature which is working perfectly), i do not get a SQL error and the database has information in it but no comments or images or anything show up, if you need additional information i can give it to you, here is my code:
Code:function login() { if(isset($_SESSION['user'])) { $user = $_SESSION['user']; echo "You are currently logged in as $user!"; } else{ if(!$_POST['submit']) { ?> <form method="post" action="index.php" class="form"> Username <input type="text" name="username" maxlength="32" style="height: 19px; width: 90px" /> Password <input type="password" name="password" maxlength="32" style="height: 18px; width: 90px" /> <input type="submit" name="submit" value="Login" style="height: 20px" /> </form> <?php } else { $user = protect($_POST['username']); $pass = protect($_POST['password']); if($user && $pass) { $sql="SELECT * FROM `testusers` WHERE `username`='$user' AND `password`='$pass'"; $query=mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($query) == 1) { $row = mysql_fetch_assoc($query); $_SESSION['user'] = $row['username']; $_SESSION['admin'] = $row['admin']; echo "$first, you are now logged in!"; } else { echo "The username and/or password you entered is invalid."; echo "<a href=\"javascript:history.go(-1)\">Try again</a> "; } } } } } ?> <?php //locate page comments function pagecomments($thread) { if(isset($_SESSION['user'])) { $sql="SELECT * FROM comments WHERE 'thread' LIKE '$thread'"; $query=mysql_query($sql) or die(mysql_error()); echo "<ol>"; while($row = mysql_fetch_array($query)) { $username=$row['username']; $text=$row['comment']; echo "<div class=\"commentbox\">"; echo "<li><i>Posted by: $username at ".$row['time']."</i><br>"; echo "<strong>$text</strong>"; echo "<i>Last Modified: ".$row['modified']."</i></li>"; echo "</div>"; commentoptions($username,$text); } echo "</ol>"; } else { echo "<i>You must be logged in to view comments.</i>"; } } function commentoptions($username,$text) { ?> <div id="commentwrapper" style="position:relative; height:3em; width:25em; margin-right:auto; margin-left:auto; text-align:left;"> <div style="position: relative; z-index: 1; width: 25em; height: 1em;" id="options"> <div style="position: relative; z-index: 1; float: left;" id="viewer"> <img alt="reply" src="images/commenticons/comment_add.png" /> <img alt="quote" src="images/commenticons/comment_quote.png" /> <img alt="report" src="images/commenticons/comment_warning.png" /> </div> <?php if($username == $_SESSION['user']) { ?> <div style="position: relative; z-index: 1; float: left;" id="poster"> <img alt="edit" src="images/commenticons/comment_edit.png" /> <img alt="notify" src="images/commenticons/comment_email.png" /> </div> <?php } if($_SESSION['admin'] == 1) { ?> <div style="position: relative; z-index: 1; float: right;" id="admin"> <img alt="delete" src="images/commenticons/comment_remove.png" /> <img alt="warn" src="images/commenticons/comment_error.png" /> <img alt="lock" src="images/commenticons/lock.png" /> <img alt="sticky" src="images/commenticons/bulb_on.png" /> <img alt="edit" src="images/commenticons/comment_edit.png" /> </div> <?php } ?> </div> </div> <?php } ?>


LinkBack URL
About LinkBacks
i am trying to create a comments feature for my website that will allow registered users to leave comments on certain pages, right now i am in the stage of getting everything to show up when a user visits that page. The problem i am having is when i go to the page there is nothing displayed (other than the login feature which is working perfectly), i do not get a SQL error and the database has information in it but no comments or images or anything show up, if you need additional information i can give it to you, here is my code:
Reply With Quote


