iamLearning Posted May 6, 2013 Share Posted May 6, 2013 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 https://forums.phpfreaks.com/topic/277707-expects-parameter-1-to-be-resource-boolean-given/ Share on other sites More sharing options...
iamLearning Posted May 6, 2013 Author Share Posted May 6, 2013 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!'; } } ?> Link to comment https://forums.phpfreaks.com/topic/277707-expects-parameter-1-to-be-resource-boolean-given/#findComment-1428624 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.