ERROR when trying to use s PHP to script to searh GOOGLE
Posted: Fri Jan 02, 2004 5:00 pm
I'm getting the folling error in the following piece of code
Warning: file("http://www.google.com/search?q=test") - Success in search.php on line 8
In the above code I'm only tring to verify that the website with the google results will be retrieved. None of the variable arguments are being used.
If I only put "http://www.google.com/" it works fine. I've tried retrieving multiple sites and they all work fine. I only get the error when pages are 404. I'm just lost as to why "http://wwww.google.com/search?q=test" gives this warning when I can browse to it easily.
Thanks in advance for any help.
Warning: file("http://www.google.com/search?q=test") - Success in search.php on line 8
Code: Select all
function search ($searchsite="test", $query="test")
{
$encodedquery = urlencode($query);
$site="http://www.google.com/search?q=test";
$results = file("$site"); //this is line 8 btw
foreach($results as $line)
{
echo $line;
}
}
search();
?>If I only put "http://www.google.com/" it works fine. I've tried retrieving multiple sites and they all work fine. I only get the error when pages are 404. I'm just lost as to why "http://wwww.google.com/search?q=test" gives this warning when I can browse to it easily.
Thanks in advance for any help.