Eugh.. got a REALLY annoying XML::Simple problem. Basically, if only one results is found, it just crashes the script (doesn't die, it just gives a blank page!).... can anyone see a problem here? The bit in red has had to be set to 1, cos if I set it to > 0, it just gives me a blank page.
It seems to be down to the first variable being accessed, but I can't work out why. Using Data::Dumper prints out the first entry, which seems to all be ok. As soon as I try to refrence it (even without the loop), with something like;
.. it doesn't print it out (not even the Listing: path) ... just gives me a blank page.
This is driving me mad
The routine is as follows ($keyword holds the corect value), and is called with;
..code is;
sub overture_run {
my $keyword = $_[0];
my $Limit = 10;
my $page = get("http://xml.uk.feed.overture.com/d/search/p/feed/xml/uk/ctxt/?mkt=uk&maxCount=11&adultFilter=clean&Partner=feed_xml_uk_ctxt&Keywords=$keyword");
if ($page !~ /Listing rank/) { return 'none found'; }
# parse the page...
my $ref = XMLin($page);
# grab the number of results we have...
my $track_hits = $ref->{ResultSet}->{numResults};
# now lets go through, and create the HTML for it...
my $html_links;
if ($track_hits > 1) {
for (my $count = 1; $count <= $track_hits; $count++) {
# get the variables all setup...
my $Description = $ref->{ResultSet}->{Listing}->[$count]->{description};
my $Title = $ref->{ResultSet}->{Listing}->[$count]->{title};
my $URI = $ref->{ResultSet}->{Listing}->[$count]->{ClickUrl}->{content};
my $ClickURL = $ref->{ResultSet}->{Listing}->[$count]->{siteHost};
# put the links into HTML format...
$html_links .= Links::SiteHTML::display('overture_link', { Description => $Description, Title => $Title, URL => $URI, ShowURL => $ClickURL });
}
}
# now lets send it back to the template....
$html_links ? return Links::SiteHTML::display('overture_search', { results => $html_links } ) : return '';
}
PLEASE someone help me here. I'm going out of my mind
TIA
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
It seems to be down to the first variable being accessed, but I can't work out why. Using Data::Dumper prints out the first entry, which seems to all be ok. As soon as I try to refrence it (even without the loop), with something like;
Code:
print "<BR>Listing: " . $ref->{ResultSet}->{Listing}->[0]->{title} . "<BR>";.. it doesn't print it out (not even the Listing: path) ... just gives me a blank page.
This is driving me mad
The routine is as follows ($keyword holds the corect value), and is called with;
Code:
$results = &overture_run($keyword);..code is;
Code:
# this is the routine that will pass back the overture results... sub overture_run {
my $keyword = $_[0];
my $Limit = 10;
my $page = get("http://xml.uk.feed.overture.com/d/search/p/feed/xml/uk/ctxt/?mkt=uk&maxCount=11&adultFilter=clean&Partner=feed_xml_uk_ctxt&Keywords=$keyword");
if ($page !~ /Listing rank/) { return 'none found'; }
# parse the page...
my $ref = XMLin($page);
# grab the number of results we have...
my $track_hits = $ref->{ResultSet}->{numResults};
# now lets go through, and create the HTML for it...
my $html_links;
if ($track_hits > 1) {
for (my $count = 1; $count <= $track_hits; $count++) {
# get the variables all setup...
my $Description = $ref->{ResultSet}->{Listing}->[$count]->{description};
my $Title = $ref->{ResultSet}->{Listing}->[$count]->{title};
my $URI = $ref->{ResultSet}->{Listing}->[$count]->{ClickUrl}->{content};
my $ClickURL = $ref->{ResultSet}->{Listing}->[$count]->{siteHost};
# put the links into HTML format...
$html_links .= Links::SiteHTML::display('overture_link', { Description => $Description, Title => $Title, URL => $URI, ShowURL => $ClickURL });
}
}
# now lets send it back to the template....
$html_links ? return Links::SiteHTML::display('overture_search', { results => $html_links } ) : return '';
}
PLEASE someone help me here. I'm going out of my mind
TIA
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

