Jump to content

expects parameter 1 to be resource, boolean given


iamLearning

Recommended Posts

I have been doing this all by myself. I have tried to only look for help when I can't find a possible fix, but I am getting very frustrated now. I have spent like an hour trying to figure out why this keeps happening. Please help me if anyone has time to look at this.

 

I am getting this error:

 

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\video.php on line 7

 

 

 

in regards to this code:

include 'dbconnect.php';
$youtubeid = ($_GET['id']); 

//Youtube video ID.
$query = mysql_query("SELECT * FROM video WHERE youtubeid='$youtubeid' ");

$numrows = mysql_num_rows($query);


	if ($numrows != 0){
		while ($row = mysql_fetch_assoc($query))
		{
			$dbyoutubeid = $row['youtubeid'];
		}
//Check to see if video exists within our database.
if ($youtubeid==$dbyoutubeid){
		//Youtube Embed 
		echo '<iframe width="560" height="315" src="http://www.youtube.com/embed/'.$youtubeid.'" frameborder="0" allowfullscreen></iframe>';
			}else{
					echo 'Sorry that video does not exist in our library!';
			}
	}
Link to comment
Share on other sites

I tried this new code, but then I received:

 


No database selected

 
 
<?php
include 'dbconnect.php';
$youtubeid = ($_GET['id']);
$youtuberesult = mysql_query('SELECT * FROM videos WHERE youtubeid LIKE $youtubeid');


//Youtube video ID.
$youtuberesult;


if($youtuberesult === FALSE) {
die(mysql_error()); // TODO: better error handling
}


while($row = mysql_fetch_array($youtuberesult))
{
 $dbyoutubeid = $row['youtubeid'];


//Check to see if video exists within our database.
if ($youtubeid==$dbyoutubeid){
//Youtube Embed 
echo '<iframe width="560" height="315" src="http://www.youtube.com/embed/'.$youtubeid.'" frameborder="0" allowfullscreen></iframe>';
}else{
echo 'Sorry that video does not exist in our library!';
}
}


?>
Edited by iamLearning
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.