doofy Posted October 2, 2012 Share Posted October 2, 2012 Essentially all I am trying to do is loop through 10 youtube videos, IF they are active videos. Right now the get_headers function seems to be stopping the while loop after the first go. I'm a newb still, so any help with this would be EXTREMELY appreciated! I'm sure it's something simple that I'm just not grasping. while($row = mysql_fetch_array($result)) { $headers = get_headers("http://gdata.youtube.com/feeds/api/videos/".$row['YouTubeURL']."?v=2&alt=jsonc"); if (strpos($headers[0], '200')) { if ($row['VideoID']!=$VideoID) { echo "<tr>"; echo "<td align='left' valign='top' width='200'>"; $json = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/".$row['YouTubeURL']."?v=2&alt=jsonc")); echo '<img src="' . $json->data->thumbnail->hqDefault . '" alt="'.$row['Title'].'" border=0 width="200">'; echo "</td>"; echo "<td align='left' valign='top' width='250'>"; if (empty($Category)) { echo "<a href='?VideoID=".$row['VideoID'].$pagelink."'>".$row['Title']."</a><br/><br/>"; } else { echo "<a href='?Category=".$row['Category']."&VideoID=".$row['VideoID'].$pagelink."'>".$row['Title']."</a><br/><br/>"; } echo "<br /><br />"; echo "<b><font size='1'>"; echo " Video Added: "; echo $row['DateStamp']; echo "</b></font><br /></tr>"; } return true; } } Quote Link to comment https://forums.phpfreaks.com/topic/269019-get_headers-for-youtube-video-validation/ Share on other sites More sharing options...
doofy Posted October 2, 2012 Author Share Posted October 2, 2012 (edited) Currently what it is doing Currently what it looked like before I was attempting to check for a 200 header. Thanks again in advance, Chris Edited October 2, 2012 by doofy Quote Link to comment https://forums.phpfreaks.com/topic/269019-get_headers-for-youtube-video-validation/#findComment-1382369 Share on other sites More sharing options...
kicken Posted October 2, 2012 Share Posted October 2, 2012 return true; } } return means that PHP will exit that function, so your first video to return a 200 status is going to cause the script to jump out of that function and back to wherever you called that function from. Near as I can tell from the code given, you probably just want to remove that line so the loop can continue. Quote Link to comment https://forums.phpfreaks.com/topic/269019-get_headers-for-youtube-video-validation/#findComment-1382374 Share on other sites More sharing options...
doofy Posted October 2, 2012 Author Share Posted October 2, 2012 That's for the heads up, I clearly am a n00b. I read about it, but couldn't figure it out. So much appreciated. I'll mark as resolved! Quote Link to comment https://forums.phpfreaks.com/topic/269019-get_headers-for-youtube-video-validation/#findComment-1382387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.