Code for google search result shown on my own site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pldh
Forum Newbie
Posts: 4
Joined: Tue Sep 08, 2009 6:14 pm

Code for google search result shown on my own site

Post 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
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

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

Post 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
pldh
Forum Newbie
Posts: 4
Joined: Tue Sep 08, 2009 6:14 pm

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

Post 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
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

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

Post 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 />";
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

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

Post by pickle »

Look up Google Custom Search (or something along those lines). Google provides this service.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

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

Post 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.
pldh
Forum Newbie
Posts: 4
Joined: Tue Sep 08, 2009 6:14 pm

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

Post by pldh »

Thanks Eric and Pickle for replying to query , Finaly i solved the problem , Thanks again
Post Reply