PHP error.

Associate
Joined
18 Nov 2003
Posts
1,311
Location
Newcastle
Anyone help me out on this one please?

Im trying to use this code on a website... but when i go to actually load the file i get...

Parse error: parse error, unexpected '}' in /usr/local/apache/htdocs/weather.php on line 16

Below is the code im trying to use. Could someone take a look at it and tell me whats up please?

Cheers. :)

PHP:
<?php
if( ! ($fp = fopen( "http://xml.weather.yahoo.com/forecastrss?p=UKXX0047&u=c","r" )) )
$xml_current_tag_state = ';
function startElementHandler( $parser, $element_name, $element_attribs )
{
global $property_data;
global $xml_current_tag_state;
$xml_current_tag_state = $element_name;
}
function endElementHandler( $parser, $element_name )
{
global $property_data;
global $xml_current_tag_state;
$xml_current_tag_state = ';
if( $element_name == "CHANNEL" );
}
function characterDataHandler( $parser , $data )
{
global $property_data;
global $xml_current_tag_state;
if( $xml_current_tag_state == ' )
{
return;
}
if( $xml_current_tag_state == "DESCRIPTION" ) {
$property_data = $property_data.$data;
}
}
if( !($xml_parser = xml_parser_create()) )
die();
if(xml_set_element_handler($xml_parser, "startElementHandler", "endElementHandler")) ;
if(xml_set_character_data_handler($xml_parser, "characterDataHandler"));
xml_set_element_handler($xml_parser, "startElementHandler", "endElementHandler");
xml_set_character_data_handler($xml_parser, "characterDataHandler");
while( $data = fread($fp, 4096) )
{
if( !xml_parse($xml_parser, $data, feof($fp)) )
{
break;
}
}
xml_parser_free($xml_parser);
$start="SP";
$find="<a href="http://weather.yahoo.com/forecast/UKXX0047.html";
$pos1=strpos($property_data, $start);
$pos2=strpos($property_data, $find);
$pos1=$pos1+2;
$pos2=$pos2-38;
echo substr($property_data, $pos1, $pos2); 
?>
 
Associate
OP
Joined
18 Nov 2003
Posts
1,311
Location
Newcastle
hmm managed to get that part to work... but one more question lol.

It displays as this...

hoo! Weather for Durham, UK
Current Conditions:
Partly Cloudy, 16 C

Forecast:
Wed - Mostly Cloudy. High: 18 Low: 11
Thu - AM Clouds/PM


How the hell do i get rid of 'hoo!' I cant find it anywhere on the code, nor the xml.

cheers :)
 
Back
Top Bottom