Jump to content

Recommended Posts

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

       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.

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.