Forum Moderators: coopster

Message Too Old, No Replies

Is this RSS Feed Code Correct?

Purchased a website and got it but it wont work?

         

newborn

3:09 pm on Jan 15, 2007 (gmt 0)

10+ Year Member



Hello guys I purchased a website which the owner did not tell me it was PHP. And Im a PHP dummy not to mention RSS dummy. I have uploaded all the files but in the php pages he has an include option for the RSS. He has an inc folder and in it a file titled rss.inc. Now I host with GoDaddy and I wanted to know if I need to do anything to make this work. More importantly is there any code anyone can offer that can work with this setup. In the index.php file the code
<?php include("inc/rss.inc");?> exists.
We want to get the google news feed for the search term acne.
HELP ANYONE WITH A CODE or a what to do on this?
Here is the code he had in the rss.inc file
<?php
/*
Created by Global Syndication's RSS Parser
I left out a link to the website/rss-parser
*/
set_time_limit(0);
$file = "http://news.google.com/news?sourceid=navclient&ie=UTF-8&rls=GGLG,GGLG:2005-22,GGLG:en&q=Acne&output=rss";
$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;
function startElement($parser, $name, $attrs) {
global $rss_channel, $currently_writing, $main;
switch($name) {
case "RSS":
case "RDF:RDF":
case "ITEMS":
$currently_writing = "";
break;
case "CHANNEL":
$main = "CHANNEL";
break;
case "IMAGE":
$main = "IMAGE";
$rss_channel["IMAGE"] = array();
break;
case "ITEM":
$main = "ITEMS";
break;
default:
$currently_writing = $name;
break;
}
}
function endElement($parser, $name) {
global $rss_channel, $currently_writing, $item_counter;
$currently_writing = "";
if ($name == "ITEM") {
$item_counter++;
}
}
function characterData($parser, $data) {
global $rss_channel, $currently_writing, $main, $item_counter;
if ($currently_writing!= "") {
switch($main) {
case "CHANNEL":
if (isset($rss_channel[$currently_writing])) {
$rss_channel[$currently_writing] .= $data;
} else {
$rss_channel[$currently_writing] = $data;
}
break;
case "IMAGE":
if (isset($rss_channel[$main][$currently_writing])) {
$rss_channel[$main][$currently_writing] .= $data;
} else {
$rss_channel[$main][$currently_writing] = $data;
}
break;
case "ITEMS":
if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
$rss_channel[$main][$item_counter][$currently_writing] .= $data;
} else {
$rss_channel[$main][$item_counter][$currently_writing] = $data;
}
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
// output HTML
// print ("<div class=\"channelname\">" . $rss_channel["TITLE"] . </div>");
if (isset($rss_channel["ITEMS"])) {
if (count($rss_channel["ITEMS"]) > 0) {
for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) {
if (isset($rss_channel["ITEMS"][$i]["LINK"])) {
print ("\n<div class=\"itemtitle\"><a href=\"" . "go.php?url=" . $rss_channel["ITEMS"][$i]["LINK"] . "\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</a></div>");
} else {
print ("\n<div class=\"itemtitle\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</div>");
}
print ("<div class=\"itemdescription\">" . $rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</div><br />"); }
} else {
print ("<b>There are no articles in this feed.</b>");
}
}
?>

monkeythumpa

10:35 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



This is better suited for the PHP section.

bill

12:19 am on Jan 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not much response to this in the RSS forum. I've moved this over to the PHP forum to see if someone there can lend a hand.

eelixduppy

4:18 am on Jan 18, 2007 (gmt 0)




I need to do anything to make this work.

Since this is a decent amount of code to debug without a problem in mind, what is the problem exactly? Are you receiving any error messages to the browser or in an error log?

If you could provide this information it would greatly increase our ability to help you out. :)