Jump to content

WAMP file_get_contents($url) problem

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
hhheng

hhheng

    Newbie

  • Members
  • Pip
  • 8 posts
I'm testing file_get_contents on my WAMP laptop (Windows Vista Home), and tried to use it to get the contents of Google, scripts are as below:

Quote

set_time_limit(10);
$result = file_get_contents("Google");
echo $result;
However I got the following errors:

Quote

Warning: file_get_contents(Google) [function.file-get-contents]: failed to open stream: HTTP request failed! in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testing\http.php on line 44
Fatal error: Maximum execution time of 10 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\testing\http.php on line 44
The allow_url_fopen is on in the php.ini, and tried change the set_time_limit to bigger or less, still the same errors.
What's wrong with the php.ini settings or wrong with the script?

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
well, if you want the content of the google webpage, you need to write it as an url, "http://www.google.com", not just google.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
hhheng

hhheng

    Newbie

  • Members
  • Pip
  • 8 posts
I do write http://www.google.com in the script, just can't understand why this site can automatically parse it to google. I tried several other urls, but got the same problem.

#4
hhheng

hhheng

    Newbie

  • Members
  • Pip
  • 8 posts
Can some expert help figure out what's wrong with the script or the settings in the php.ini in my wamp laptop?