Jump to content

confused with rss in php


Porkie

Recommended Posts

 

 

<?php
echo '<?xml version="1.0" ?>';
echo '<rss version="2.0">';

echo '<channel>'; // Opens our main content
echo '<title>Test Website RSS Feed</title>';    // Defines the title of the RSS feed
echo '<link>http://www.testsite.com</link>';    // Where the RSS feed is from
echo '<description>This RSS feed is all about the pie.</description>'; // What its about

$c = mysqli_connect('localhost', '', '', '') or die(mysqli_error($c)); // Connect with our information
$q = mysqli_query($c, 'SELECT * FROM news ORDER BY id DESC LIMIT 5') or die(mysqli_error($c)); // Query the table for 5 news articles sorting by 'id'
while($r = mysqli_fetch_assoc($q)) // While there is more rows to get (max of 5) we get an associative array
{

echo '<item>'; // Begin a news article
echo '<title>'.$r['title'].'</title>'; // Give it a title
echo '<link>'.$r['permalink'].'</link>'; // The link to the article
echo '<description>'.$r['content'].'</description>'; // The description or content of the article
echo '<author>'.$r['author'].'</author>'; // The author
echo '<pubDate>'.$r['date'].'</pubDate>'; // The date is was published
echo '</item>'; // End news article
} // End while statement

echo '</channel>';
echo '</rss>';
/>

 

im confused as when i load it up i get an error saying

 

"XML Parsing Error: no element found

Location: http://www.quad.co.uk/test1.xml

Line Number 27, Column 3:?>

--^"

 

where could i be going wrong?

 

thanks in advance

 

Link to comment
https://forums.phpfreaks.com/topic/170149-confused-with-rss-in-php/
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.