[PHP] Strange results from file_get_contents using an url as filename
I'm getting unexpected data from my file_get_contents function using an url as filename. The function does not return false, i do get data from it. Problem is that is is not the data is requested. $data = file_get_contents(http://somehost.com/xmlonl.asp?custid=00prodid=0 ); if ($data) { ... the string this function returns is the webpage from the default website of the server where this php code is running at and not the data from the remote site (which is not on the same server). i tried the url from my shell on the server using telnet and it gets the data i expected. I can't figure out why php is getting the wrong results while telnet on the same host gets the correct data. Is this a (known) error with php or is it a apache/php/server configuration problem ? regards, Ewout -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange results from file_get_contents using an url as filename
On Tuesday 28 December 2004 20:03, Ewout de Boer wrote: $data = file_get_contents(http://somehost.com/xmlonl.asp?custid=00prodid= 0 ); if ($data) { ... the string this function returns is the webpage from the default website of the server where this php code is running at and not the data from the remote site (which is not on the same server). Have you tried other URLs? With and without a query string? Could you give a _real life_ example of a URL that doesn't work? i tried the url from my shell on the server using telnet and it gets the data i expected. I can't figure out why php is getting the wrong results while telnet on the same host gets the correct data. Is this a (known) error with php or is it a apache/php/server configuration problem ? One possible explanation as to why it doesn't work within PHP but works with something else is that the target site looks at the user-agent in the request header and if it finds something it doesn't like (eg PHP) then it redirects the request to http://localhost/ or something. That way the target site hopes to prevent bots from harvesting its data. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* I didn't want a hokey second wedding like those ones on TV! This one's for real! -- Homer Simpson A Milhouse Divided */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange results from file_get_contents using an url as filename
Ewout de Boer wrote: I'm getting unexpected data from my file_get_contents function using an url as filename. The function does not return false, i do get data from it. Problem is that is is not the data is requested. $data = file_get_contents(http://somehost.com/xmlonl.asp?custid=00prodid=0 ); if ($data) { ... the string this function returns is the webpage from the default website of the server where this php code is running at and not the data from the remote site (which is not on the same server). i tried the url from my shell on the server using telnet and it gets the data i expected. I can't figure out why php is getting the wrong results while telnet on the same host gets the correct data. Is this a (known) error with php or is it a apache/php/server configuration problem ? regards, Ewout *Check your PHP runtime config to see if 'allow_url_fopen' is enabled. (You can view your configuration using 'phpinfo'. You can change it in your php.ini file.) (See the first tip in the fine manual: http://us4.php.net/manual/en/function.file-get-contents.php ) ** -John * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [SOLVED] Re: [PHP] Strange results from file_get_contents using an url as filename
I'm getting unexpected data from my file_get_contents function using an url as filename. The function does not return false, i do get data from it. Problem is that is is not the data is requested. The ISP made a mistake in the server config :-( ... it works again regards, Ewout -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php