lunkan1245 Posted March 30, 2014 Share Posted March 30, 2014 Hi Im trying to display my comments in i while loop thats inside another while loop but im getting an error and I looked through my code and i cant see whats wrong with it. Can someone plz help me to see were the problem is? The comments are still inserted into the database but is not shown. The error is the second while loop, this line while ( $rows = mysqli_fetch_array($results)) <?php //loopar igenom databasen för bilderna $query = "SELECT * FROM bilder"; $result = mysqli_query($dbc, $query); while ( $row = mysqli_fetch_array($result)) {?> <a href="bilder/<?php echo $row['namn'];?>" data-init="mbox" data-type="image" class="mbox"><img src="thumb_bilder/<?php echo $row['namn'] ;?>" width="300" height="200"/><span class="mbox-descr"><span class="information"> <?php echo $row['username'];?><br /> <?php echo $row['datum'];?><br /><br /> <?php echo $row['kommentar'];?><br /> <p style="border-bottom:1px solid grey; margin-top:80px; margin-bottom:30px;"></p> <?php echo $row['kamera'];?><br /><?php echo $row['objektiv'];?><br /> <p style="border-bottom:1px solid grey; margin-top:80px; margin-bottom:30px;"></p> <img src="img/slutartid.png" class="smabilder"/><?php echo $row['slutartid'];?><br /> <img src="img/blandare.png" class="smabilder"/><?php echo $row['blandare'];?><br /><img src="img/skarpdjup.png" class="smabilder"/> <span class="skarpdjup"><?php echo $row['skarpdjup'];?></span><br /> <img src="img/iso.png"/ class="smabilder"><?php echo $row['iso'];?> <form method="post" action="includes/insert.php" class="img_comment"><textarea name="kommentar" placeholder="comment" class="comment"></textarea><br /><input type="hidden" name="hidden" value="<?php echo $row['img_id']?>"/><input type="submit" name="submit" value="skicka" class="skicka"></form><div class="svar"><?php $value = (isset($_POST['hidden'])); $querys = "SELECT * FROM kommentarer where img_id = $value"; $results = mysqli_query($dbc, $querys) or die(mysqli_error($dbc)); while ( $rows = mysqli_fetch_array($results)) { $comment = $rows['kommentar']; $uppladdare = $rows['username']; echo $comment; echo "<br />"; echo $uppladdare; echo "<br />"; } ?></div></span></span></a> <?php } ?> Quote Link to comment Share on other sites More sharing options...
boompa Posted March 30, 2014 Share Posted March 30, 2014 You don't even have a mysql_num_rows() call in that code, but as always with this error, the answer is: Your query failed, and you never bothered to check. It's #6 is the README: PHP Resources & FAQs thread stuck at the top of the forum page: http://forums.phpfreaks.com/index.php?act=findpost&pid=1428660 Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 31, 2014 Share Posted March 31, 2014 $value = (isset($_POST['hidden'])); $querys = "SELECT * FROM kommentarer where img_id = $value"; $value is being set to a Boolean (i.e. True/False) not to the value passed in the hidden field. That is probably the source of your problem. Try $value = isset($_POST['hidden']) ? intval($_POST['hidden']) : 0; 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.