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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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