Jump to content

Warning mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given


lunkan1245

Recommended Posts

 

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
					
				}

?>
Link to comment
Share on other sites

 

$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;
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.