Jump to content

PHP problems with RSS feed


rockon

Recommended Posts

Hey guys.

 

I'm going crazy trying to figure out what is wrong here:

 

I'm trying to utilize this for adding relevant youtube videos to my site depending on the artist page:

 

http://pimpmypagerank.com/2008/12/embed-a-youtube-video-in-your-page-based-on-a-keyword-from-rss-feed/

 

The type of page it would appear on is here:

 

http://megalyrics.net/view-442347-boys_like_girls_the_great_escape.html

 

 

Basically, when I enter the code given by that website appropriately it makes my page mess up by stopping any code after it from working. Here is the code for my "view-item" page:

 

<?php

include './include.php';

include_once("config.inc.php");
include_once("db_connect.php");

// get vars
$j    = $_REQUEST['j'];
$r    = $_REQUEST['r'];

if(!$j) {

$ptitle    = "ERROR";
$meta_keys = "search, lyrics, $title, tunes, singing, words, toons, viewing";

$meta_desc = "ERROR";
$selected  = "VIEW";

include("header.php");

echo "<b>ERROR!</b><br><br>No lyrics were requested, please go back to the homepage and start again.<br>";

}
else {

$vote = $_REQUEST['vote'];
if($vote) {
  $lookup_field = "votestar".$vote;
  $get_values   = mysql_query("SELECT votestar1, votestar2, votestar3, votestar4, votestar5 FROM tracks WHERE id = ".$j." LIMIT 1");
  $votestar1 = mysql_result($get_values, 0, votestar1);
  $votestar2 = mysql_result($get_values, 0, votestar2);
  $votestar3 = mysql_result($get_values, 0, votestar3);
  $votestar4 = mysql_result($get_values, 0, votestar4);
  $votestar5 = mysql_result($get_values, 0, votestar5);
  if($vote == 1) $votestar1 = $votestar1+1;
  elseif($vote == 2) $votestar2 = $votestar2+1;
  elseif($vote == 3) $votestar3 = $votestar3+1;
  elseif($vote == 4) $votestar4 = $votestar4+1;
  elseif($vote == 5) $votestar5 = $votestar5+1;
  $total = ($votestar1 * 1)+($votestar2 * 2)+($votestar3 * 3)+($votestar4 * 4)+($votestar5 * 5);
  $total = $total/($votestar1+$votestar2+$votestar3+$votestar4+$votestar5);
  $update_joke = mysql_query("UPDATE tracks SET ".$lookup_field." = ".$$lookup_field.", votestartotal = ".$total." WHERE id = ".$j." LIMIT 1");
}

$lyricsqry = mysql_query("SELECT artist, album, title, dateadded, artwork, views, votestartotal FROM tracks WHERE id = ".$j." LIMIT 1");
if($lyricsqry) {
  $artist        = mysql_result($lyricsqry, 0, artist);
  $album         = mysql_result($lyricsqry, 0, album);
  if(strlen($album) == 0) $album = "Unknown";
  $title         = mysql_result($lyricsqry, 0, title);
  $dateadded     = mysql_result($lyricsqry, 0, dateadded);
  $dateadded     = substr($dateadded, 8, 2)."/".substr($dateadded, 5, 2)."/".substr($dateadded, 0, 4);
  $artwork       = mysql_result($lyricsqry, 0, artwork);
  $views         = mysql_result($lyricsqry, 0, views);
  $votestartotal = mysql_result($lyricsqry, 0, votestartotal);

  $lyricsqry2 = mysql_query("SELECT lyrics FROM lyrics WHERE trackid = ".$j." LIMIT 1");

  $lyrics        = wordwrap(stripslashes(nl2br(mysql_result($lyricsqry2, 0, lyrics))), 100, "\n", true);



  $newviews = $views+1;
  $update = mysql_query("UPDATE tracks SET views = ".$newviews." WHERE id = ".$j." LIMIT 1");
}
else die("ERROR LOOKING UP LYRICS");

$ptitle    = $title." lyrics by ".$artist."";
$meta_keys = str_replace(" ", ", ", $title)." lyrics, ".$artist." lyrics, ".$album." lyrics, search, lyrics, song lyrics, popular lyrics, amazon, music, tunes, mp3s, sing, karaoke";
$meta_desc = $title." lyrics by ".$artist.". Find more ".$artist." lyrics at megalyrics.net";
if($r == 1) $selected = "RANDOM";
else $selected  = "VIEW";

include("header.php");

?>


<table width="100%" cellspacing="5" cellpadding="0">
  <tr>
    <td valign="top">
	<?php
	  echo "<table width='100%' cellspacing='0' cellpadding='0'>";
	  echo "<tr><td colspan='2' class='headertitle'><b>";
	  if($r == 1) echo "Random";
	  else echo "Viewing";
	  echo " Lyrics for ".$title.":</b><br><br></td></tr>";
	  echo "<tr><td width='90'><font class='listingtitle'>Artist:</font></td><td>".$artist."</td><td rowspan='11' valign='top' style='margin-top: 0px; padding-top: 0px;'><table width='100%' cellspacing='0' cellpadding='0' style='margin-top: -30px; padding-right:10px;'>
		<tr><td align='right'>";

		echo show_artwork($j, 150);

		echo "</td></tr>";

		  echo "<tr><td align='right' class='buylink'><br class='smallBr'><a href='http://www.amazon.com/s/?tag=meglyr-20&creative=392013&campaign=212361&link_code=wsw&_encoding=UTF-8&search-alias=aps&field-keywords=".$artist."&Submit.x=0&Submit.y=0&Submit=Go' target='_blank' class='buylink'>Purchase this from<br><br class='smallBr'><img src='themes/".$theme."/images/icon-amazon.jpg' width='120px' border='0'></a><br/><br/><a href='http://www.cduniverse.com/sresult.asp?HT_Search_Info=".$artist."&HT_Search=Artist&GO.x=4&GO.y=11&GO=Go+Find+It!&frm=lk_megalyr'><img src='http://www.cduniverse.com/banners/live/cdu/88x31_music/88x31_music01.gif' width='88' height='31' border='0' alt='CD Universe - Buy Music CDs, TV on DVD, DVDs, Blu-ray, Video Games for Wii, XBox360, PlayStation 3 and Much More'></a<br/><br/><br/></td></tr>";






  echo "<tr><td align='right'>";

echo "<b>Add these lyrics to your page</b><br/><br/>";

echo "<table width='165px;' cellpadding='2' cellspacing='0' style='border: 1px solid #CCC;'><tr><td style='background-color: #b6d3e9; border-bottom: 1px solid #CCC;' align='left'><b>".$artist."</b><br/>".$title."</td><td align='right' style='background-color: #b6d3e9; border-bottom: 1px solid #CCC;'>".show_artwork($j, 40)."</td></tr><tr><td colspan='2' style='background-color: #f6f6f6;'><marquee style='text-align: center; background-color: #f6f6f6;' direction='up' onmouseover='this.stop()' scrollamount='2' onmouseout='this.start()' height='220'>".$lyrics."</marquee></td></tr><tr><td colspan='2' align='right' style='background-color: #b6d3e9;'><a href='http://www.megalyrics.net' alt='Visit Mega Lyrics' border='0'><img src='http://www.megalyrics.net/themes/1/images/widget_icon.jpg' border='0' /></a></td></tr></table>";



echo "<br/><textarea style='width: 160px;'><table width='165px;' cellpadding='2' cellspacing='0' style='border: 1px solid #CCC;'><tr><td style='background-color: #b6d3e9; border-bottom: 1px solid #CCC;' align='right'><b>".$artist."</b><br/>".$title."</td><td align='right' style='background-color: #b6d3e9; border-bottom: 1px solid #CCC;'>".show_artwork($j, 40)."</td></tr><tr><td colspan='2' style='background-color: #f6f6f6;'><marquee style='text-align: center; background-color: #f6f6f6;' direction='up' onmouseover='this.stop()' scrollamount='2' onmouseout='this.start()' height='220'>".$lyrics."</marquee></td></tr><tr><td colspan='2' align='right' style='background-color: #b6d3e9;'><a href='http://www.megalyrics.net' alt='Visit Mega Lyrics' border='0'><img src='http://www.megalyrics.net/themes/1/images/widget_icon.jpg' border='0' /></a></td></tr></table></textarea>";

echo "<br/><br/></td></tr>";






echo "<tr><td align='right'>";

echo "<b>More "; echo UCWords($artist); echo " lyrics</b>";

echo "</td></tr>";

  $temp = mysql_query("SELECT id, title, artist FROM tracks WHERE artist = '$artist' ORDER BY RAND() LIMIT 15");
  echo "<tr><td><table width='100%' cellspacing='3' cellpadding='0'>";

  while($row = mysql_fetch_array($temp)) {
    echo "<tr><td style='text-align: right;' class='xlistingtitle'><a href='view-".$row[id]."-".urlconvert($row[artist])."_".urlconvert($row[title]).".html' class='morelink'>".$row[title]."</td></tr>";

  }
  echo "</table></td></tr><br>";















	  echo "</table>

	  </td></tr>";
	  echo "<tr><td width='90'><font class='listingtitle'>Album:</font></td><td>".$album."</td></tr>";
	  echo "<tr><td width='90'><font class='listingtitle'>Track:</font></td><td>".$title."</td></tr>";

	  echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>";
	  echo "<tr><td style='padding-top:4px;'><font class='listingtitle'>Date Added:</font></td><td style='padding-top:4px;'>".$dateadded."</td></tr>";
	  if(number_format($votestartotal, 0) == 0) $rating = "not yet rated";
	  else $rating = number_format($votestartotal, 0)." stars";
	  echo "<form method='POST' action='view-".$j."-".trim(substr(urlconvert($joke), 0, 50)).".html'><tr><td style='padding-top:4px;'><font class='listingtitle'>Rating:</font></td><td style='padding-top:4px;'><img src='themes/".$theme."/images/small-stars-".number_format($votestartotal, 0).".gif' width='52' height='8' alt='".$rating."'>";
	  if(!$vote) echo "   <select name='vote' class='smallform'>
	    <option value=''>< rate ></option>
		<option value='1'>1 out of 5</option>
		<option value='2'>2 out of 5</option>
		<option value='3'>3 out of 5</option>
		<option value='4'>4 out of 5</option>
		<option value='5'>5 out of 5</option>
	  </select>  <input name='submit' type='submit' value='rate now' class='smallform'>";
	  echo "</td></tr></form>";
	  echo "<tr><td style='padding-top:4px;'><font class='listingtitle'>Views:</font></td><td style='padding-top:4px;'>".$newviews."</td></tr>";

	  echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>";
	  echo "<tr><td valign='top' style='padding-top:4px;'><font class='listingtitle'>Lyrics:</font></td><td valign='top' style='padding-top:4px;'><div style='margin: 0px; padding: 0px; width: 360px;'>".$lyrics."<br/>[ Brought to you by www.megalyrics.net ]</div></td></tr><tr><td> </td><td></td></tr>";

	  echo "<tr><td style='padding-top:4px;'></td><td> </td></tr>";
	  $this_url   = $site_path."view-".$j."-".urlconvert($artist)."_".urlconvert($title).".html";
	  $this_title = $title." by ".$artist." lyrics";
	  echo "</table>";

	?>

	</td>
  </tr>
</table>

<br/>



<br/>


<center>
<table style="padding-left: 10px; padding-right: 10px; border-top: 1px solid #ccc;" width="100%">
  <tr>
  	<td>
  		If you find a mistake in any of the lyrics please do not hesitate to send us any corrections. Use the form on the <a href="\contact-us.html">contact</a> page and use the subject <i>"Lyric Correction"</i>.
  	</td>
  </tr>
</table>
<br>
<table width="100%" style="padding-left: 10px; padding-right: 10px;" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left" valign="top">
		<?php
		echo $c5t_output;
		?>
	</td>
	<td align="right" valign="top" style="padding-top: 8px;">
		<!-- Begin: AdBrite, Generated: 2009-11-11 11:59:11  -->
		<script type="text/javascript">
		var AdBrite_Title_Color = '414D6C';
		var AdBrite_Text_Color = '000000';
		var AdBrite_Background_Color = 'FFFFFF';
		var AdBrite_Border_Color = 'CCCCCC';
		var AdBrite_URL_Color = '453159';
		try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==''?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe='';var AdBrite_Referrer='';}
		</script>
		<script type="text/javascript">document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(' src="http://ads.adbrite.com/mb/text_group.php?sid=1412512&zs=3136305f363030&ifr='+AdBrite_Iframe+'&ref='+AdBrite_Referrer+'" type="text/javascript">');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script>
		<div><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=1412512&afsid=1" style="font-weight:bold;font-family:Arial;font-size:13px;">Your Ad Here</a></div>
		<!-- End: AdBrite -->
	</td>
  </tr>
</table>
<br>
<table width="100%">
  <tr>
  	<td align="center">
  	<br/>
  	<iframe src="http://rcm.amazon.com/e/cm?t=meglyr-20&o=1&p=13&l=ur1&category=music&banner=1DDZ5PY330HYPB7Q0BG2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>

	</td>
  </tr>
</table>
</center>
<br/>










<?php
}
?>

<?php
include("footer.php");
?>

 

 

And the code to add the youtube rss function is this:

 

<?php

//Give our script a keyword to work with
$keyword="george bush";

//Generate a URL for our RSS feed, and download the feed using SimpleXML
$rss = simplexml_load_file('http://gdata.youtube.com/feeds/base/videos?q=' .urlencode($keyword). '&client=ytapi-youtube-search&v=2');

//Get the part of the RSS feed which contains the number of the first video, and save it to the variable $id
$id = $rss->entry->id;

//Get rid of some stuff we don't need
$id = str_replace("tag:youtube.com,2008:video:", "", $id);

?>


<embed src="http://www.youtube.com/v/<?php echo $id; ?>&hl=en&fs=1&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="265"></embed>

 

Any idea what's wrong with it?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/181297-php-problems-with-rss-feed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.