3

Scratching my head a bit now with this.
I am trying to get a file from a remote url. I can save contents from local files, but can't from remote.

This works:

file_put_contents(
    'file1.xml',
    file_get_contents('file2.xml')
);

This doesn't:

file_put_contents(
    'file1.xml',
    file_get_contents('http://www.domain.com/xmlapi/search.aspx?query=places&lid=38')
);

Oddly enough my other scripts worked ok at first try but none will access the remote url now.
I have recently started to host my new php files on Heart Internet. I have similar scripts on other servers which give no problems at all.

This is the error I get:

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/sites/mydomain/myfile.php on line 5`

Warning: file_get_contents(http://www.domain.com/xmlapi/search.aspx?query=places&lid=38) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/sites/mydomain/public_html/myfile.php on line 5`

allow_url_fopen is set to On

Different domains

Community
  • 1
  • 1
Oldbej
  • 31
  • 1
  • 3

2 Answers2

5

check the php settings...

it may be due to security issue... "allow_url_fopen = On"

http://www.php.net/manual/en/function.file-get-contents.php

KoolKabin
  • 17,157
  • 35
  • 107
  • 145
1

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/sites/mydomain/myfile.php on line 5`

This would suggest you are either using an incorrect url, or DNS is not correctly set up on your server.

Evert
  • 93,428
  • 18
  • 118
  • 189