
September 30th, 2004, 03:21 PM
|
|
Contributing User
|
|
Join Date: Jun 2004
Posts: 73
Time spent in forums: < 1 sec
Reputation Power: 5
|
|
|
RSS feed + PHP
As a PHP file my code works correctly, atleast it displays correctly - however Live bookmarking does not.
As an XML file it does not work in the slighest - infact it just displays the PHP.
This is my first day at XML and Im utterly confused! Help
PHP Code:
<?php
define("SECURITY_KEY", true);
include("includes/connect.php");
function escape_upper_chars($text) {
// 32-90, 97-122
for ($x = 0; $x < strlen($text); $x++) {
$w = $text{$x};
if ((ord($w) < 32) || ((ord($w) > 90) && (ord($w) < 97)) || (ord($w) > 122)) {
$q .= '&#'.ord($w).';';
} else {
$q .= $w;
}
}
return $q;}
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>
<rss version=\"0.91\">
<channel>
<title>Wuggawoo RSS feed</title>
<language>en</language>
<link>http://www.wuggawoo.com</link>
<description>Wuggawoo new post monitor</description>\n
<items>";
$limit = (int)$_GET['limit'];
if (($limit < 1) || ($limit > 50)) {$limit = 15;} // Set the default number of results
$s = mysql_query("SELECT * FROM $forumzDB.forumz_threads ORDER BY lp_time DESC LIMIT $limit");
while($thread = mysql_fetch_object($s)) {
$title = stripslashes(escape_upper_chars($thread_title));
echo "<item>\n"; // Begin a new item
echo "<title>$thread->thread_title</title>\n"; // Send the title
echo "<link>http://forumz.wuggawoo.co.uk/index/thread/$thread->tid</link>\n";
echo "<description>".date("l dS of F @ h:ia", $thread->lp_time)."</description>\n";
echo "</item>\n"; //End the item
}
echo "</items></channel>\n</rss>"; // Close the RSS channel
?>
|