XML and PHP - dynamic hell
| From: | Chris | Date: | Sat, 01 Dec 2001 05:34:23 +0000 |
| Subject: | XML and PHP - dynamic hell | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-76293@lists.php.net to get a copy of this message | ||
I'm having one page output XML for other sites to parse. Unfortunately if I
give an RSS parser the site (the php file) it errors out. But if I put the
output in a XML file, and give that to the RSS parser everything works
perfectly. Does anyone know why it can't read it straight from the php file?
PHP Builder has it working, I have no idea why mine doesn't. Thanks
Source:
<?
require "division/settings.inc";
require RootPath . "admin/Admin.php"; //these just define mysql logins and
such
echo "<" . "?xml version=\"1.0\"?" . ">\n";
echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"
\"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n";
echo "<rss version=\"0.91\">\n";
echo "<channel>\n";
$query = mysql_query("Select * from " . PREFIX . "news order by Date Desc
Limit 40");
while($results = mysql_fetch_array($query))
{
echo "<item>\n";
echo "<title>" . stripslashes($results["Subject"]) .
"</title>\n";
echo "<link>http://dod.stronger.org/</link>\n";
echo "<author>$results[Name]</author>\n";
echo "<description>" .
substr(htmlspecialchars(stripslashes($results["News"])),0,150) .
"...</description>\n";
echo "</item>\n";
}
?>
</channel>
</rss>