queerfm
04-06-2008, 03:11 PM
Hey guys, having some problems with this script i made based on the skynews rss feed.
if anyone can tell me what is going wrong that would be great.
a demo can be seen at http://www.twitoosearch.com/podcast/rss.php
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "test";
$pass = "test";
$database = "test";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT * FROM news ORDER BY id DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output = "<rss version=\"2.0\">\n";
$xml_output .= "<channel>\n";
$xml_output .= "<title>Twitoosearch - News</title>\n";
$xml_output .= "<link>http://www.twitoosearch.com/?p=News</link>\n";
$xml_output .= "<image>http://static.sky.com/images/skynews/rss/rss.gif<title>Twitoosearch - News</title><url>http://static.sky.com/images/skynews/rss/rss.gif</url><link>http://www.twitoosearch.com/?p=News</link></image>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<item>\n";
$xml_output .= "\t\t<date>" . $row['date_time'] . "</date>\n";
// Escaping illegal characters
$row['title'] = str_replace("&", "&", $row['title']);
$row['title'] = str_replace("<", "<", $row['title']);
$row['title'] = str_replace(">", ">", $row['title']);
$row['title'] = str_replace("\"", """, $row['title']);
$xml_output .= "\t\t<title>" . $row['title'] . "</title>\n";
$xml_output .= "\t\t<link>news.twitoosearch.com/" . $row['title'] . "</link>\n";
$xml_output .= "\t\t<description>" . $row['intro'] . "</description>\n";
$xml_output .= "\t</item>\n";
}
$xml_output .= "</channel>";
$xml_output .= "</rss>";
echo $xml_output;
?>
any help thanked in advance
if anyone can tell me what is going wrong that would be great.
a demo can be seen at http://www.twitoosearch.com/podcast/rss.php
<?php
header("Content-type: text/xml");
$host = "localhost";
$user = "test";
$pass = "test";
$database = "test";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$query = "SELECT * FROM news ORDER BY id DESC";
$resultID = mysql_query($query, $linkID) or die("Data not found.");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output = "<rss version=\"2.0\">\n";
$xml_output .= "<channel>\n";
$xml_output .= "<title>Twitoosearch - News</title>\n";
$xml_output .= "<link>http://www.twitoosearch.com/?p=News</link>\n";
$xml_output .= "<image>http://static.sky.com/images/skynews/rss/rss.gif<title>Twitoosearch - News</title><url>http://static.sky.com/images/skynews/rss/rss.gif</url><link>http://www.twitoosearch.com/?p=News</link></image>\n";
for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){
$row = mysql_fetch_assoc($resultID);
$xml_output .= "\t<item>\n";
$xml_output .= "\t\t<date>" . $row['date_time'] . "</date>\n";
// Escaping illegal characters
$row['title'] = str_replace("&", "&", $row['title']);
$row['title'] = str_replace("<", "<", $row['title']);
$row['title'] = str_replace(">", ">", $row['title']);
$row['title'] = str_replace("\"", """, $row['title']);
$xml_output .= "\t\t<title>" . $row['title'] . "</title>\n";
$xml_output .= "\t\t<link>news.twitoosearch.com/" . $row['title'] . "</link>\n";
$xml_output .= "\t\t<description>" . $row['intro'] . "</description>\n";
$xml_output .= "\t</item>\n";
}
$xml_output .= "</channel>";
$xml_output .= "</rss>";
echo $xml_output;
?>
any help thanked in advance