This does not tell you how many videos it found, only whether or not MySQL was able to parse and execute the query:
$videoquery = mysql_query("SELECT * FROM `video` WHERE `youtubeid` = '$youtubeid'");
if ($videoquery == 0) {
echo 'Sorry this video does not exist in our library!';
exit;
}
I like to define the query string first as a variable, so that I can output it with the debug info if needed. You can then use mysql_num_rows() to determine if it found anything at all:
$sql = "SELECT * FROM `video` WHERE `youtubeid` = '".mysql_real_escape_string($youtubeid)."'";
$videoquery = mysql_query($sql);
if($videoquery == false) {
error_log(mysql_error().PHP_EOL.$sql);
die("Sorry, there was an unexpected DB error. Debug data has been logged");
}
elseif(mysql_num_rows($videoquery) == 0 ) {
echo 'Sorry this video does not exist in our library!';
exit;
}
else {