Jump to content


RSS Feeds and PHP


3 replies to this topic

#1 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 13 September 2007 - 09:34 PM

I am trying to create an rss feed that is automaticly updated with php, the only problem is all the tutorials on this site just say to add the php to the file and when i do the file gives me errors. This is the error I get:

The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

XML document must have a top level element. Error processing resource 'http://www.toon-workshop.net/rss/index.php'.

And this is the code im using in a file called index.php:

<? header('Content-type: text/xml'); ?>
 
<?php
include ('../includes/db_config.php');
 
mysql_select_db('chrimail_login') or die (mysql_error()); // Selecting Database
?> 
 
<rss version="2.0">
<channel>
	<title>Test Title</title>
	<description>This is an example description</description>
	<link>http://pixel2life.com</link>
 
<?
$sql = "SELECT * FROM topics WHERE fid = 9 LIMIT 5";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){
?>
 
<item>
	 <title><?=$row['title']; ?></title>
	 <author><?=$row['author']; ?></author>
	 <link>http://MYSITE.com/news.php?id=<?=$row['id']; ?></link>
</item>
 
<?
}
?>
 
</channel>
</rss>

Edited by Hip Hop Artist, 13 September 2007 - 09:50 PM.


#2 Braunson

    Young Padawan

  • Members
  • Pip
  • 237 posts
  • Gender:Male
  • Location:Ontario, Canada

Posted 13 September 2007 - 11:45 PM

I'll send you mine HHA, Remind me when i get on tomorrow :)

Edited by Braunson, 13 September 2007 - 11:45 PM.


#3 Hip Hop Artist

    Young Padawan

  • Members
  • Pip
  • 152 posts
  • Gender:Male
  • Location:Canada

Posted 14 September 2007 - 10:51 AM

lol k

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 September 2007 - 02:58 PM

<?php
header('Content-type: text/xml');
include ('../includes/db_config.php');

mysql_select_db('chrimail_login') or die(mysql_error()); // Selecting Database
?>
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
You forgot the xml header tag (<?xml...)

Edited by rc69, 14 September 2007 - 02:58 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users