I keep getting this error in line 54 and I don't know why. All that I'm trying to do is to process the first entry of the query result: extract it's URL so as to construct an embeddable video object.
<?php
function extractID($youtubeURL)
{
//split off the final bit of the URL beginning with ‘=’
$youtubeID = strchr($youtubeURL,'=');
//remove that equals sign to get the video ID
$youtubeID = substr($youtubeID,1);
return $youtubeID;
}
?>
<?php
// set feed URL
$lang = $_POST['language'];
$query = $_POST['query'] . "%20review";
switch($lang){
case "English":
$feedURL = <<<URL
http://gdata.youtube.com/feeds/api/videos
?q=<?php echo $query; ?>
&v=2
&format=5
&lr=en
URL;
break;
case "French":
$feedURL = <<<URL
http://gdata.youtube.com/feeds/api/videos
?q=<?php echo $query; ?>
&v=2
&format=5
&lr=fr
URL;
break;
case "Spanish":
$feedURL = <<<URL
http://gdata.youtube.com/feeds/api/videos
?q=<?php echo $query; ?>
&v=2
&format=5
&lr=es
URL;
break;
}
// read feed into SimpleXML object
$sxml = simplexml_load_file($feedURL);
// get the first media entry &
// get nodes in media: namespace for media information
$media = $sxml->entry[0]->children('http://search.yahoo.com/mrss/');
// get video player URL
$attrs = $media->group->player->attributes();
// **THIS KEEPS CAUSING THE ERROR.**
$videoURL = $attrs['url'];
// extract the video's ID from the URL
$videoID = extractID($videoURL);
?>
<?php
echo <<<EOD
<objectwidth="425" height="350" data="http://www.youtube.com/v/
<?php echo $videoID ?>
type="application/x-shockwave-flash"><param name="src"
value="http:/www.youtube.com/v/<?php echo $videoID ?>" /></object>
EOD;
?>