0

yesterday some pages have returned this error: Error 500: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known I tried to search this problem in relation with Yii framework but I did not found no solutions to this issue.

bit
  • 427
  • 1
  • 6
  • 14
  • Can you show us the code on the error line. I am just guessing that the file url that you provided to `file_get_contents` doesn't exists anymore. (Check that url). If it is on the same server try checking permissions. – Think Different Apr 17 '14 at 09:32
  • Can you put your code here so, i can review it. ? I think you need to describe more. – Jigar Chaudhary Apr 17 '14 at 09:32
  • Links are randomly generated with Crypt PHP library using RSA For this reason I cannot know what was the link which generated the error – bit Apr 17 '14 at 09:37
  • then you should use `curl` to check if the url for the file is valid (file exists). – Think Different Apr 17 '14 at 09:40
  • However, I must to check any generated link before to launch brower request? So, I don't understand why this problem is occurred now. This web platform is active from 2 months and there have never been any problem of this type. – bit Apr 17 '14 at 09:43
  • You can use the code in my answer to find if the url is active (exists). – Think Different Apr 17 '14 at 09:44
  • It seems that the error is due to the HTML refresh that I put for refresh page every hour. But what is the relation with the problem? – bit Apr 17 '14 at 10:12
  • I utilise [phpseclib](http://phpseclib.sourceforge.net/rsa/examples.html) – bit Apr 17 '14 at 10:26

1 Answers1

1

try checking the URLs like this :

$ch = curl_init($url); //<=== YOUR URL

curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// if $retcode >= 400 -> not found else if $retcode = 200, found.
curl_close($ch);
Think Different
  • 2,815
  • 1
  • 12
  • 18
  • unfortunately, checking the result (200 or 500) gives me the same error even when the result is 200 – bit Jun 09 '14 at 09:24