How do a create RSS using PHP and MySQL

2015-03-17T17:45:16

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

About “How do a create RSS using PHP and MySQL” questions

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: ...
Basically I need to create a PHP document that will read an RSS feed and the write the information to a MySQL document. However I have very little experience in this area and I was wondering if som...
So I have RSS feed of 10 000 records in file.xml (I collected them from 10 feeds in 1 hour time so there timestamps will not help, btw I used yahoo pipes). I need some class to simulate that records
I have created an RSS feed php file in php which is connected to MySQL. Based on ID, if you click on RSS links it will generate an RSS feed for everyone. But I want to know how can I link my RSS fe...
I'm trying to build a simple RSS feed for multiple users but i am facing problems with mysql and the feed. Ive done a showrss.php and an RSS.php I have followed a tutorial on this, and it works as
I have absolutely no idea how to start one. Every tutorial I find assumes I have a cms or blog of some sort. Mine's not exactly. I upload everything and coded all my css, html, mysql, php, and such...
Is there a good PHP Class to generate a RSS file from mysql tables?
I'm having some difficulty getting this script to execute properly. The create_rss function does not create the RSS file when the remote function updateStatus is called. &lt;?php define("DB_HOST...
I have a cms website where I need to import wordpress extended rss file to my mysql database using php. I am also using phpmyadmin for this.
I need to create a database of items from rss feeds and I'd like it to be updated asynchronously (via push ala AJAX) rather than pull (ala scraping RSS via python/magpie in php). The database will be

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.