c_pattle Posted November 22, 2010 Share Posted November 22, 2010 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 More sharing options...
GKWelding Posted November 22, 2010 Share Posted November 22, 2010 does article_title work? also, without seeing the initial SQL query and table structure we can't really help you much? Link to comment https://forums.phpfreaks.com/topic/219448-php-to-rss-problem/#findComment-1137871 Share on other sites More sharing options...
c_pattle Posted November 22, 2010 Author Share Posted November 22, 2010 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 More sharing options...
c_pattle Posted November 22, 2010 Author Share Posted November 22, 2010 Everyone works. For example when I view the source code for my feed the "article_type" has data in it but for some reason it isn't showing up at all. Link to comment https://forums.phpfreaks.com/topic/219448-php-to-rss-problem/#findComment-1137887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.