You are here:  » Search results working for single word searches but not 2-3 etc...


Search results working for single word searches but not 2-3 etc...

Submitted by adam on Tue, 2006-05-09 18:08 in

I'm creating a new website - TheWorldNewsHeadlines.com - which brings up news results from google, msn and yahoo...

I have used pricetapestry to handle the search facility and magicparser to display the results and everything seems to be working fine with single word searches...

If I enter a search, lets say Iraq War...nothing comes up...

Iraq search here works fine - http://www.theworldnewsheadlines.com/search.php?q=Iraq

I am using the following details to pull up the results:

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
{
    print 
"<b><font size='2' face='Arial, Helvetica, sans-serif'><a href='".$record["LINK"]."'>".$record["TITLE"]."</a></font></b>";
    print 
"<br><font size='2' face='Arial, Helvetica, sans-serif'>".$record["TITLE"]."</font></br>";
    print 
"<hr noshade='noshade' color='F0F0F0'>";
}
  
$url "http://news.google.com/news?q=$q&output=RSS&ned=us&lang=en"
  
MagicParser_parse($url,"myRecordHandler","xml|RSS/CHANNEL/ITEM/");
?>

Can you see anything im doing wrong...this is the first time i've parsed RSS feeds and can't figure it out?!

Thanks
Adam

Submitted by support on Tue, 2006-05-09 18:41

Hello Adam,

I think this is because you need to urlencode your value for $q when you construct your URL. Otherwise, the URL is invalid and I think Google will be returning nothing.

Where you make $url, just change it to this:

$url = "http://news.google.com/news?q=".urlencode($q)."&output=RSS&ned=us&lang=en";

Hope this helps!
Cheers,
David.