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!';
			}
	}

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!';
}
}


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.