Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    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>";
            
        }
                
    ?>
    ** 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).
    Last edited by Joseph Witchard; 06-13-2009 at 09:18 AM.


 

Posting Permissions

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