Jump to content

[SOLVED] RSS Feeds


Xelex

Recommended Posts

I'm trying to create an RSS feed that dynamically updates in PHP...

And I've managed to create a few question...

 

When I try to run the script, I get this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/******/rss1.php:9) in /home/****/*****/****/rss1.php on line 48/promo.rss?promoid=1707&token=cd0bad28f52a7bf7b509e751915d72f57dfdb35c5f7eedb50176437a5c2881a2Sun, 10 Feb 2008 22:11:00 -0800

( Starred out file paths for security )

 

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>RSS Feed</title>
</head>

<body>
<?php 
    /**
    * Work on a database to store this information.
    */
    $channel = array("title"        => "RSS Feeds",
                     "description"  => "RSS Feed Example",
                     "link"         => "*******",
                     "copyright"    => "Copyright NA");

    $items = array(
        array("title"       => "EB Games",
              "description" => "Stuff on EB Games",
              "link"        => "**********",
              "pubDate"     => date("D, d M Y H:i:s O", mktime(22, 11, 0, 1, 41, 2008)))
        , array("title"       => "Hotwire Hotel",
                "description" => "Hotwire Deals",
                "link"        => "********",
                "pubDate"     => date("D, d M Y H:i:s O", mktime(22, 11, 0, 1, 41, 2008)))
    );

    $output = '<?xml version="1.0" encoding="ISO-8859-1"?>';
    $output .= '<rss version="2.0">';
    $output .= "<channel>";
    $output .= "<title>" . $channel["title"] . "</title>";
    $output .= "<description>" . $channel["description"] . "</description>";
    $output .= "<link>" . $channel["link"] . "</link>";
    $output .= "<copyright>" . $channel["copyright"] . "</copyright>";

    foreach ($items as $item) {
        $output .= "<item>";
        $output .= "<title>" . $item["title"] . "</title>";
        $output .= "<description>" . $item["description"] . "</description>";
        $output .= "<link>" . $item["link"] . "</link>";
        $output .= "<pubDate>" . $item["pubDate"] . "</pubDate>";
        $output .= "</item>";
    }
    $output .= "</channel>";
    $output .= "</rss>";

    header("Content-Type: application/rss+xml; charset=ISO-8859-1");
    echo $output;
?>
</body>
</html>

 

Also, the information that shows up in the variables, such as the link and description show up on the page AFTER the error, as in as regular text right next to the error as if I loaded up an HTML file with only text.

I'm guessing it's probably a stupid mistake, or I don't have my server configured properly....

Also, I'm not quite sure how RSS parses out information... Have any sources that explains what it does to pull and display it's information/title?

 

You guys have been very helpful, thank you, by the way =)

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.