Page 1 of 1

Code for google search result shown on my own site

Posted: Tue Sep 08, 2009 6:24 pm
by pldh
Hi All

I want to implement google search box on my site with the condition that whenever i search something , then the results gets displayed on my site , instead of showing it on google.
Kindly help me , i need to implement it on my site as soon as possible.

Thanks ALL

Dsingh

Re: Code for google search result shown on my own site

Posted: Tue Sep 08, 2009 7:10 pm
by Eric!
The easiest way for someone new to do something like this is just to try to copy some tutorial and use a tool someone built (JSON).
http://dev-tips.com/featured/php-tip-ad ... e-with-php

Re: Code for google search result shown on my own site

Posted: Wed Sep 09, 2009 1:04 am
by pldh
Thanks for replying , I have used the code but I'am getting warning like this one , same shown on http://dev-tips.com/featured/php-tip-ad ... e-with-php .

“Warning: Invalid argument supplied for foreach() in /home/irishtit/public_html/09/querygoogle.php on line 29″

Please help

Re: Code for google search result shown on my own site

Posted: Wed Sep 09, 2009 11:14 am
by Eric!
Did you read the comments about that problem on the page you got the code from and then look at line 9? I think it is a problem with the URL not being passed through urlencode properly.

Put this line at Line 10 and post the results back here.

Code: Select all

echo "URL=".htmlentities($url)."<br />";

Re: Code for google search result shown on my own site

Posted: Wed Sep 09, 2009 2:33 pm
by pickle
Look up Google Custom Search (or something along those lines). Google provides this service.

Re: Code for google search result shown on my own site

Posted: Wed Sep 09, 2009 3:48 pm
by Eric!
@pickle The example I linked uses google's Custom Search Engine (CSE) API for searching via php. The links on google (which seem to be broken) use javascript for their CSE API.

Re: Code for google search result shown on my own site

Posted: Wed Sep 09, 2009 5:34 pm
by pldh
Thanks Eric and Pickle for replying to query , Finaly i solved the problem , Thanks again