Jump to content

PHP to RSS problem


c_pattle

Recommended Posts

Hi everyone.  I have written a PHP script gets data from a MySQL database and attempts to convert it to an RSS feed.  The problem I am having is that when I preview the feed the "article_type", "article_author", "article_author2" and "article_company" information is not showing up in the feed.  Have I coded this wrong?  Thanks for any help. 

 

while($rss_array = mysql_fetch_array($rss_rs))
	{
		$xml .= "<item><title><![CDATA[" . $rss_array['article_title'] . "]]></title>
					 <link><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></link><guid><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></guid><description><![CDATA[" . str_replace("'", "", $rss_array['article_description']) . "]]></description>
					<article_type>" . $rss_array['article_type'] . "</article_type>
					<article_author>" . $rss_array['article_author'] . "</article_author>
					<article_author2>" . $rss_array['article_author2'] . "</article_author2>
					<article_company>" . $rss_array['article_company'] . "</article_company>
				 </item>";
	}

 

 

Link to comment
https://forums.phpfreaks.com/topic/219448-php-to-rss-problem/
Share on other sites

Sorry I just didn't want to post loads of code.  Here is the full script below.  Everything works fine except for those "article_type", "article_author"...

 

$rss_sql = "select * from articles where article_verification=\"1\" order by article_number desc limit 0, 10";
$rss_rs = mysql_query($rss_sql, $mysql_conn);

	$xml = '<?xml version="1.0" encoding="US-ASCII"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
			<channel>
<atom:link href="rss.xml" rel="self" type="application/rss+xml" />
			<title>Professional Perspectives - RSS Feed</title>
			<link>http://www.pperspectives.co.uk</link>
			<description>the best industry-lead opinions, insights and forecasts - direct</description>
			<language>en-us</language>';

while($rss_array = mysql_fetch_array($rss_rs))
	{
		$xml .= "<item><title><![CDATA[" . $rss_array['article_title'] . "]]></title>
					 <link><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></link><guid><![CDATA[index.php?skip=true&article=" . $rss_array['article_number'] . "]]></guid><description><![CDATA[" . str_replace("'", "", $rss_array['article_description']) . "]]></description>
					<article_type>" . $rss_array['article_type'] . "</article_type>
					<article_author>" . $rss_array['article_author'] . "</article_author>
					<article_author2>" . $rss_array['article_author2'] . "</article_author2>
					<article_company>" . $rss_array['article_company'] . "</article_company>
				 </item>";
	}
	$xml .= "</channel>
			 </rss>";

$file= fopen("rss.xml", "w");
fwrite($file, $xml);
fclose($file);

Link to comment
https://forums.phpfreaks.com/topic/219448-php-to-rss-problem/#findComment-1137873
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.