www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Help Me Fix My RSS Feed

  1. #1
    Join Date
    Dec 2007
    Location
    Mississippi
    Posts
    1,063

    resolved [RESOLVED] Help Me Fix My RSS Feed

    I built it with PHP, but the problem seems to be XML related. That's why I'm posting it here. This is my first attempt at an RSS feed, so go easy on me. I was able to bookmark the feed in Firefox, but when you go to the bookmark, it says "Live bookmark feed failed to load."

    PHP Code:
    <?php

        
    /** Coded by: Jeffrey (Joseph Witchard)
         ** Created on: 06/13/09
         ** Last modified: 06/13/09
         ** Purpose: To syndicate Rebirth news
         **          via RSS. */
         
         // configure to XML
         
         
    header("Content-Type: application/xml; charset=utf-8");
         
         
    // include the connection setting
         
         
    require('path_to_connection');
         
         
    // set up the connection
         
         
    $conn access_function();
         
         
    // set up the query
         
         
    $query "SELECT post_id, author_name, DATE_FORMAT(date_posted, '%W, %M %d, %Y %l:%i %p') AS formatted_date, author_email, description, a.category_id, c.category_name, title FROM posts a INNER JOIN categories c ON a.category_id = c.category_id ORDER BY post_id LIMIT 10";
         
         
    // start pulling out the data
         
         
    if ($stmt $conn->prepare($query))
         {
         
            
    $stmt->execute();
            
            
    $stmt->bind_result($postID$author$date$email$post_desc$cat_id$cat_name$post_title);
            
            echo 
    '<?xml version="1.0"?>';
            
            echo 
    '<rss version="2.0">';
            
            echo 
    "<channel>";
            
            while (
    $stmt->fecth())
            {
            
                echo 
    "<item>";
                
                echo 
    "<title>$post_title</title";
                
                echo 
    "<link>http://www.uhrebirth.com/show_news/$postID</link>";
                
                echo 
    "<description>$post_desc</description>";
                
                echo 
    "<pubDate>$date</pubDate>";
                
                echo 
    "<author>$author</author>";
                
                echo 
    "<managingEditor>$email</managingEditor>";
                
                echo 
    "<webMaster>josephwitchard@uhrebirth.com</webMaster>";
                
                echo 
    "<category>$cat_name</category>";
                
                echo 
    "</item>";
                
            }
            
            echo 
    "</channel>";
            
            echo 
    "</rss>";
            
            echo 
    "</xml>";
            
        }
                
    ?>

  2. #2
    Join Date
    Dec 2007
    Location
    Mississippi
    Posts
    1,063
    I got it working. Aside from all of the syntax errors, I didn't realize that XML tags were messing it up; I assumed they would be required. Now I need to know how to add a title to it, because when I bookmark the feed now, the default title is http://www.uhrebirth.com/rss.php (the URL to the feed).

  3. #3
    Join Date
    Jul 2009
    Posts
    2
    Looks to me like you need a title for your channel, not just the item.

    Sample RSS 2.0 compliant XML here,

    Code:
    <?xml version="1.0"?>
    <rss version="2.0">
       <channel>
          <title>Liftoff News</title>
          <link>http://liftoff.msfc.nasa.gov/</link>
          <description>Liftoff to Space Exploration.</description>
          <language>en-us</language>
          <pubDate>Tue, 10 Jun 2003 04:00:00 GMT</pubDate>
          <lastBuildDate>Tue, 10 Jun 2003 09:41:01 GMT</lastBuildDate>
          <docs>http://blogs.law.harvard.edu/tech/rss</docs>
          <generator>Weblog Editor 2.0</generator>
          <managingEditor>editor@example.com</managingEditor>
          <webMaster>webmaster@example.com</webMaster>
          <item>
             <title>Star City</title>
             <link>http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp</link>
             <description>How do Americans get ready to work with Russians aboard the International Space Station? They take a crash course in culture, language and protocol at Russia's &lt;a href="http://howe.iki.rssi.ru/GCTC/gctc_e.htm"&gt;Star City&lt;/a&gt;.</description>
             <pubDate>Tue, 03 Jun 2003 09:39:21 GMT</pubDate>
             <guid>http://liftoff.msfc.nasa.gov/2003/06/03.html#item573</guid>
          </item>
          <item>
             <description>Sky watchers in Europe, Asia, and parts of Alaska and Canada will experience a &lt;a href="http://science.nasa.gov/headlines/y2003/30may_solareclipse.htm"&gt;partial eclipse of the Sun&lt;/a&gt; on Saturday, May 31st.</description>
             <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate>
             <guid>http://liftoff.msfc.nasa.gov/2003/05/30.html#item572</guid>
          </item>
          <item>
             <title>The Engine That Does More</title>
             <link>http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp</link>
             <description>Before man travels to Mars, NASA hopes to design new engines that will let us fly through the Solar System more quickly.  The proposed VASIMR engine would do that.</description>
             <pubDate>Tue, 27 May 2003 08:37:32 GMT</pubDate>
             <guid>http://liftoff.msfc.nasa.gov/2003/05/27.html#item571</guid>
          </item>
          <item>
             <title>Astronauts' Dirty Laundry</title>
             <link>http://liftoff.msfc.nasa.gov/news/2003/news-laundry.asp</link>
             <description>Compared to earlier spacecraft, the International Space Station has many luxuries, but laundry facilities are not one of them.  Instead, astronauts have other options.</description>
             <pubDate>Tue, 20 May 2003 08:56:02 GMT</pubDate>
             <guid>http://liftoff.msfc.nasa.gov/2003/05/20.html#item570</guid>
          </item>
       </channel>
    </rss>

  4. #4
    Join Date
    Dec 2007
    Location
    Mississippi
    Posts
    1,063

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles