I want to create a RSS Feed from MySQL with PHP and I am going mad here trying to get something to work, this is new to me so any help would be greatly appreciated. Here is code I have grabbed online and adapted in file name, [feed.php]
- Code: Select all
<?
// create rss content
$hostname_solutions = "io.my_site_name.com";
$database_solutions = "my_database_name";
$username_solutions = "my_user_name";
$password_solutions = "my_pw";
$solutions = mysql_pconnect($hostname_solutions, $username_solutions, $password_solutions) or trigger_error(mysql_error(),E_USER_ERROR);
$result = mysql_query("SELECT *
FROM `solutions`
WHERE 1
LIMIT 0 , 30");
$date = date("D, j M Y G:i:s O");
header('Content-type: text/xml');
echo ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
echo ("<rss version=\"2.0\">\n");
echo ("<channel>\n");
echo ("<lastBuildDate>$date</lastBuildDate>\n");
echo ("<pubDate>$date</pubDate>\n");
echo ("<title>My_Feed_Title</title>\n");
echo ("<description><![CDATA[My_Feed_Description]]></description>\n");
echo ("<link>http:_site_link</link>\n");
echo ("<language>en-us</language>\n");
$ch=100;
while ($data = mysql_fetch_array($result)) {
$headline = $data["headline_field"];
$posturl = $data["url_field"];
$content = $data["content_field"];
echo ("<item>\n");
echo ("<title>$headline</title>\n");
echo ("<link>$posturl</link>\n");
echo ("<description><![CDATA[$content]]></description>\n");
echo ("<guid isPermaLink=\"true\">$posturl</guid>\n");
echo ("</item>\n");
}
echo ("</channel>\n");
echo ("</rss>\n");
?>
When I link to feed.php it shows up fine, but reports "No Articles" - can anyone help?