I tried making an RSS feed that loads data from my SQL database.
When I run it, either it takes me to the RSS reader on my internet browser and says "no content", or it will return an error:
This page contains the following errors: error on line 2 at column 1: Extra content at the end of the document Below is a rendering of the page up to the first error.
I am using Dreamweaver to make the RSS and am creating it on a PHP file.
<?php require_once('Connections/mydatabase.php'); ?>
<?php
header('Content-type: text/xml');
$mydatabase = mysqli_connect("http://127.0.0.1","root","au291826","db_cms");
$rss = '<?xml version="1.0" encoding="utf-8"?>';
$rss .= '<rss version="2.0">';
$rss .= '<channel>';
$rss .= '<title>My RSS</title>';
$rss .= '<link>http://localhost/cws_files/</link>';
$rss .= '<description>implementation of RSS with PHP </description>';
$rss .= '<language>ar-sa</language>';
$rss .= '<copyright> RSS </copyright>';
mysql_select_db($database_mydatabase, $mydatabase);
$query_getRecent = "
SELECT news.post_id, news.title
FROM news
ORDER BY news.updated
DESC LIMIT 10
";
$getRecent = mysql_query($query_getRecent, $mydatabase) or die(mysql_error());
$totalRows_getRecent = mysql_num_rows($getRecent);
while ($row_getRecent = mysql_fetch_assoc($getRecent)){
$rss .= '<item>';
$rss .= '<link>
http://localhost/cws_files/index.php?post_id=' . $row_getRecent['post_id'] . '
</link>';
$rss .= '<title>' . $row_getRecent['news.title'] . '</title>';
$rss .= '</item>';
}
$rss .= '</channel>';
$rss .= '</rss>';
echo $rss;
?>
Copyright License:
Author:「Andrew Udoh」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/29095824/how-do-a-create-rss-using-php-and-mysql