Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 307997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:36:35+00:00 2026-05-12T07:36:35+00:00

I am having a problem doing a get on googles search url from php.

  • 0

I am having a problem doing a get on googles search url from php. Here’s the code I have:

<?php
    $handle = fopen("http://www.google.com/complete/search?hl=en&js=true&qu=" .
        $_GET["qu"], "r");
    while (!feof($handle)) {
        $text = fgets($handle);
        echo $text;
    }
    fclose($handle);
?>

Here’s the error I get:

PHP Warning:
fopen(http://www.google.com/complete/search?hl=en&js=true&qu=cat):
failed to open stream: A connection
attempt failed because the connected
party did not properly respond after a
period of time, or established
connection failed because connected
host has failed to respond. in
C:\Inetpub\test\google.php on line 3
PHP Fatal error: Maximum execution
time of 60 seconds exceeded in
C:\Inetpub\test\google.php on line 3

I’m using fiddler, and doing a request on the url itself works fine, but for some reason the php does not. Anyone have any idea why?

update: Here is my javascript:

function getSuggest(keyEvent) {
  keyEvent = (keyEvent) ? keyEvent : window.event;
  input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;

  if (keyEvent.type == "keyup") {
    if (input.value) {
      getSearchData("google.php?qu=" + input.value);
    } else {
 var target = document.getElementById("targetDiv");
 target.innerHTML = "<div></div>";
    }
  }
}

function getSearchData(dataSource) {
  if (XMLHttpRequestObject) {
    XMLHttpRequestObject.open("GET", dataSource);
 XMLHttpRequestObject.onreadystatechange = function() {
   if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
     eval(XMLHttpRequestObject.responseText);
        }
 }
    XMLHttpRequestObject.send(null);
  }
}

function sendRPCDone(unusedVariable, searchTerm, arrayTerm, arrayResults, ususedArray) {
  var data = "<table>";
  var loopIndex;

  if (arrayResults.length != 0) {
    for (var loopIndex = 0; loopIndex < arrayResults.length; loopIndex++) {
 data += "<tr><td>" + "<a href='http://www.google.com/search?q=" +
   arrayTerm[loopIndex] + "'>" + arrayTerm[loopIndex] + '</a></td><td>' +
   arrayResults[loopIndex] + "</td></tr>";
    }
  }

  data += "</table>";
  var targetDiv = document.getElementById("targetDiv");
  targetDiv.innerHTML = data;
}

And here is my html:

<div id="googleSearch">
  Search For <input id="textField" type="text" name="textField" onkeyup="getSuggest(event)" />
  <div id="targetDiv4"></div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:36:36+00:00Added an answer on May 12, 2026 at 7:36 am

    Edit:

    If it turns out you are having user agent string problems, you can set the user-agent php uses by creating and running a file with the following code in it:
    <?php ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1) Gecko/20090615 Firefox/3.5'); ?>

    I think you’ll have to restart IIS after setting this, but not 100% on that.

    Note: this is a random user agent string I pulled, there are many out there, you can set it to pretty much anything you want. There are many more at: http://www.useragentstring.com/


    To check if allow_url_fopen is on, do this:

    1. Create a php file on your server, name it whatever you desire.
    2. Put this into your file <?php phpinfo(); ?>
    3. Execute the script on your server through a web browser or fiddler if you are using that
    4. check for all necessary settings.

    Let us know what it is, then we can walk you through setting it to what you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 188k
  • Answers 188k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Turns out I needed Microsoft.VisualStudio.Tools.Applications.Hosting.dll installed to the GAC. I… May 12, 2026 at 5:35 pm
  • Editorial Team
    Editorial Team added an answer Under the Project Options in D2009, there is an "Enable… May 12, 2026 at 5:35 pm
  • Editorial Team
    Editorial Team added an answer An extract of your code : $mysqli = new mysqli("localhost",… May 12, 2026 at 5:35 pm

Related Questions

I am using a similar approach to others in keeping my LINQ objects in
I am having a problem using Indy HTTP (in Delphi) with the Google Contacts
I am having a bit of a problem with a functor (and it's resultant
I'm having a problem with a query prepared in PHP with PDO. The code:

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.