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