I have a loop going through results from a youtube feed and it works fine but towards the end it fails with the error:
Warning: main() [function.main]: Node no longer exists in ../youtubereader.php on line 8
Warning: main() [function.main]: Node no longer exists in .../youtubereader.php on line 8
Fatal error: Call to a member function attributes() on a non-object in .../youtubereader.php on line 9
My code is:
<?php
error_reporting(E_ALL);
$feedURL = 'http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?max-results=50';
$sxml = simplexml_load_file($feedURL);
$i=0;
foreach ($sxml->entry as $entry) {
$media = $entry->children('media', true);
$watch = (string)$media->group->player->attributes()->url;
$thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
?>
<div class="videoitem">
<div class="videothumb"><a href="<?php echo $watch; ?>" class="watchvideo"><img src="<?php echo $thumbnail;?>" alt="<?php echo $media->group->title; ?>" /></a></div>
<div class="videotitle">
<h3><a href="<?php echo $watch; ?>" class="watchvideo"><?php echo $media->group->title; ?></a></h3>
<p><?php echo $media->group->description; ?></p>
</div>
</div>
<?php $i++; if($i==3) { echo '<div class="clear small_v_margin"></div>'; $i=0; } } ?>
My xml comes back from youtube fine and there are definitely more results than where it breaks, any ideas why it would do this?
Edit: Tested locally, using wamp and it works fine. Still not on server. Live, the thumbnails after item 24 no thumbnails are returned.