php_network_getaddresses 오류관련 질문드립니다.
본문
php_network_getaddresses: getaddrinfo failed: No address associated with hostname(0) Warning: fclose(): supplied argument is not a valid stream resource
이 오류가 발생해서 그런데
현재 소스코드를 보니
$fp = @fsockopen($host,80,$errno,$errstr,30);
$return = "";
if (!$fp) {
echo $errstr."(".$errno.")";
} else {
fputs($fp, "POST ".$path." HTTP/1.1\r\n");
fputs($fp, "Host: ".$host."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($param)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $param."\r\n\r\n");
while(!feof($fp)) $return .= fgets($fp,4096);
}
fclose ($fp);
이렇게 작성되어있는데
$fp = @fsockopen($host,80,$errno,$errstr,30);
$return = "";
if (!$fp) {
echo $errstr."(".$errno.")";
} else {
fputs($fp, "POST ".$path." HTTP/1.1\r\n");
fputs($fp, "Host: ".$host."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($param)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $param."\r\n\r\n");
while(!feof($fp)) $return .= fgets($fp,4096);
fclose ($fp);
}
fclose($fp)를 else문에 넣으면 오류가 수정될까요..??
답변 2
fclose ($fp); <--- @fclose ($fp); @만 먼저 붙혀보세요
No address associated with hostname(0)
이 부분을 해결하셔야할거같은데요
fclose부분은 warning이라 치명적인 오류가 아닌거같아요