Jump to content

[SOLVED] file_get_contents with get request


iwarlord

Recommended Posts

I'm having some problems using file_get_contents on my local server.

 

$text= file_get_contents("file.php");

 

works fine as expected but...

 

$text= file_get_contents("file.php?id=1");

 

...throws a warning "Warning: file_get_contents(file.php?id=1) [function.file-get-contents]: failed to open stream: No error". Putting the url in a browser works correctly though.

Obvious it has to do with the get request but...

 

$text= file_get_contents("http://www.google.com/search?hl=en&q=bpatterson&btnG=Google+Search");

 

...works like it should.

 

I tried using the full URL of file.php but then I get 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. . Also, no luck with using the full file path from root.

 

I tried url_encode which gave me failed to open stream: No such file and a 403 error when using the encoded url in a browser. I guess maybe its a server config problem??? but I wouldn't know what to change.

 

Any ideas?

Thanks

 

I tried using the full URL of file.php
Post what you tried. xxxxxx out any sensitive information in the URL, but don't change any of the syntax.

 

Also, does file.php use sessions or cookies to allow access to it?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.