Help With RSS Generator

phpnutphpnut Junior MemberShared Hoster
Okay, I've written some PHP that should generate an RSS feed for me, but it doesn't seem to even create the file. Please help!

[PHP]<?php
$dbhost = "*****";
$dbuser = "*****";
$dbpass = "*****";
$db = "sitemembers";
$connect = mysql_connect($dbhost,$dbuser,$dbpass)
or die(mysql_error());
$selectdb = mysql_select_db($db,$connect)
or die(mysql_error());
$query = "SELECT id,title,author FROM poetry";
$result = mysql_query($query)
or die(mysql_error());
$xmlname = "poetryrss.xml";
$xmlcreate = fopen($xmlname,'w')
or die("Cannot generate RSS feed.");
$xmldata = "
<xml version=\"1.0\" >
<rss version=\"2.0\">

<channel>

<title>The Essence of Nature: Poetry Feed</title>
<description>Great poetry delivered straight to you!</description>
<link>***naturesmagazine.com</link>";
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
$xmldata =. "
<item>
<title>$title</title>
<description>By $author</description>
<link>***naturesmagazine.com/membership/displayPoem.php?id={$id}</link>
</item>";
}
$xmldata =. "
</channel>
</rss>";
$xmlwrite = fwrite($xmlcreate,$xmldata)
or die("Cannot generate RSS feed.");
$xmldone = fclose($xmlcreate);
?>
[/PHP]
My ongoing projects...
www.naturesmagazine.com
www.energyreform.org *new domain*
www.photographyavenue.com
----
You may also remember me as imnewtophp...

Comments

  • phpnutphpnut Junior Member Shared Hoster
    Okay... this is extremely odd. I fixed the PHP and it creates the file (had the periods in the wrong space to join the variable) but Safari doesn't want to read the file for some reason! Any suggestions?
    feed://naturesmagazine.com/membership/poetryrss.xml
    My ongoing projects...
    www.naturesmagazine.com
    www.energyreform.org *new domain*
    www.photographyavenue.com
    ----
    You may also remember me as imnewtophp...
  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    The prefix feed:// opens up in microsoft outlook...shouldn't it be [url]http://?[/url]

    and if you use http://
    XML Parsing Error: xml declaration not at start of external entity
    Location: http://naturesmagazine.com/membership/poetryrss.xml
    Line Number 2, Column 1:<?xml version="1.0"?>
    ^

    just a heads up, its not valid xml

    and don't you have to throw in a header("content-type: something"); somewhere?
    ban1.gif
  • AeriffAeriff Junior Member Shared Hoster
    danielneri wrote:
    The prefix feed:// opens up in microsoft outlook...shouldn't it be [url]http://?[/url]

    and if you use http://



    just a heads up, its not valid xml

    and don't you have to throw in a header("content-type: something"); somewhere?

    the feed:// protocol is associated with an external program, so yes, it would essentially be http:// ... Maybe the feed:// protocol you're using for your external rss program doesnt work in Safari?

    Also, instead of using header(); just place <?xml version="1.0" encoding="UTF-8"?> at the top of your RSS and it should get recognized as valid xml..
  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    the feed:// protocol is associated with an external program

    thats exactly what i meant...:p
    ban1.gif
  • AeriffAeriff Junior Member Shared Hoster
    danielneri wrote:
    thats exactly what i meant...:p

    It doesnt even open in Outlook for me, though, seeing as I refuse to install it. :p
Sign In or Register to comment.