Not able to show data in page

i have done as shown in this pic but its not working for me

Please tell me what you mean by ā€œnot working for meā€. What happens?

What happens if you open the page as I suggested above?

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\site\admin\post.php on line 38
Call Stack
# Time Memory Function Location
1 0.0007 402824 {main}( ) ā€¦\post.php : 0
2 0.0060 452264 mysqli_num_rows( ) ā€¦\post.php : 38

And what value are you putting in the address for ā€˜idā€™?

ā€˜booleanā€™ in this location tells you the attempt to run the query returned ā€˜falseā€™ instead of a results object.

i got that error when i put this as you said ?id=1

[off-topic]
@srsingh83, if you include a hash mark ( # ) in your post you need to escape it for it to show up, that means, typing a backslash \ before the hash - ie you need to type \#
[/off-topic]

where to write it - #

Typo in this line?

"select * from comments where vid='$id' And  Status='approved' order by id DESEC";

? what to do here thing this will come up when the above error get solved:)

Iā€™m not sure what you mean. I think thereā€™s a typing error in your query which is stopping it from running. When it doesnā€™t run, it returns ā€˜falseā€™, which you should check for before your code continues. As you donā€™t, you then try to count the number of rows returned by the query, but instead of a results object you are passing in ā€˜falseā€™ to the function. So you get the error message you posted.

thatā€™s why i asked for the help as i am not able to get whats wrong in the code

also i posted the pic from where i am writing the code it works but mine not

Wherever you have a # in your post.

Thatā€™s fine, but forum help is generally to point you in the right direction rather than to just do the fixes for you. I think Iā€™ve found the line of code thatā€™s causing the problem (though Iā€™m not 100% certain) - can you compare it to the line in the code that you downloaded? You didnā€™t show that line in your screen-shots in post #21 so Iā€™m not sure itā€™s the same.

yes i know forum is here to help thats why i am asking the help that whats gone wrong in the code

i have applied the code formatting and this is the updated and full code - post #21 is not there it was blank to applied the formatting and you can see now the things clearly

		<?php
		if ( isset( $_REQUEST[ 'id' ] ) ) {
			$id = $_REQUEST[ 'id' ];
		}

		$query2 = "select * from video where vid='$id'";
		$sql2 = mysqli_query( $con, $query2 );
		$row2 = mysqli_fetch_assoc( $sql2 );

		?>

		<iframe src="https://www.youtube.com/embed/<?php echo $row2['link'];?>" height="300" width="400" scrolling="no" frameborder="0"></iframe>
		<h1>
			<?php echo $row2['title'];?>
		</h1>
		<p>
			<?php echo $row2['description'];?>
		</p>

		<?php
		$query4 = "select * from comments where vid='$id' And  Status='approved' order by id DESEC";
		$sql = mysqli_query( $con, $query4 );
		if ( mysqli_num_rows( $sql ) > 0 ) {
			while ( $row4 = mysqli_fetch_array( $sql ) ) {
				?>

		<div class="comment">
			<p>
				<?php echo $row4['comment'];?>
			</p>
			<p>
				<?php echo "From ". $row4['uid'];?>
			</p>

		</div>
		<?php
		}

		}

		if ( isset( $_POST[ 'submit' ] ) ) {
			if ( empty( $_POST[ 'email' ] ) || empty( $_POST[ 'comment' ] ) ) {

				$erro = "<p class='text-danger'> Fill the Required Fields</p>";


			} else {

				$Commentquery = "insert into comments (vid,uid,status,comments,datetime) values ('$id','$_POST[email]', 'pending','$_POST[comment]',now())";

				if ( mysqli_query( $con, $Commentquery ) ) {

					$sucess = "<p class='text-sucess'> Thankyou</p>";

				}
			}
		}
		?>

		<div class="comment_form">
			<h2> Comment on post</h2>

			<?php
			if ( isset( $err ) ) {
				echo $err;
			}
			if ( isset( $sucess ) ) {
				echo $sucess;
			}

			?>

			<form method="post" action="">
				<div class="form-group">
					<lable> Email Address</lable>
					<input type="email" name="email" class="form-control"/>
				</div>
				<div class="form-group">
					<lable> Comment</lable>
					<textarea name="comment" class="form-control" cols="40" rows="4"></textarea>
				</div>
				<div class="form-group">
					<input type="submit" name="submit" class="btn btn-default"/>
				</div>


			</form>

		</div>

the pic are from video so cannot post the code from it

Where is this being set?

I believe (though I may be wrong) that the problem lies in the query in this line of code:

$query4="select * from comments where vid='$id' And  Status='approved' order by id DESEC";

which causes it not to run. Could you go through the query keyword by keyword, and see where there might be something spelled incorrectly?

When you then try to execute the query in this line

$sql = mysqli_query( $con, $query4 );

it returns false into $sql, because the query has a syntax error. So then when you run this line

if ( mysqli_num_rows( $sql ) > 0 ) {

you get the error message you gave us in post #23,

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\site\admin\post.php on line 38

because youā€™re passing in $sql as parameter 1, which is now false, a Boolean value.

So, have a careful look through each keyword in that query, until you see which one is wrong.

When itā€™s called from the browser line, I think - that must be OK, because itā€™s not mentioning the undefined variable any more.

1 Like

this is the last points my current problem is not solved yet

<?php
			if ( isset( $_REQUEST[ 'id' ] ) ) {
				$id = $_REQUEST[ 'id' ];
			}

			$query2 = "select * from video where vid='$id'";
			$sql2 = mysqli_query( $con, $query2 );
			$row2 = mysqli_fetch_assoc( $sql2 );

			?>

			<iframe src="https://www.youtube.com/embed/<?php echo $row2['link'];?>" height="300" width="400" scrolling="no" frameborder="0"></iframe>
			<h1>
				<?php echo $row2['title'];?>
			</h1>
			<p>
				<?php echo $row2['description'];?>
			</p>

and i think if this solved the others can also be solved as the id is causing the issue

the further section is for the comment section which has to come after the video got display any my video is not coming so how to solve further thing first :slight_smile:

Hang on, the last error message you asked for help with was the fault with the second query, where you are passing false into it. What is your ā€œcurrent problemā€?

i showed up the full code for the page but first showed the id error which not solved and then i showed you that what i am trying to do

first to display video with title and description and then comment thing