Jump to content

warining in fopen


hemi19

Recommended Posts

Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\examples\htl.php on line 12

 

Warning: fopen(http://www.google.com) [function.fopen]: failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\wamp\www\examples\htl.php on line 12

 

---------------------------------------------------------------------------------------------

actually my code is to get the view source of a web page, but when i enter any url it is displaying the above warning .

 

-----------------------------------------my code is

<?php

 

error_reporting (E_ALL ^ E_NOTICE);

 

if(isset($_POST['submit']))

{

$domain = $_POST['domain'];

//$htmlval=file_get_contents('http://google.com');

 

 

echo"name is $domain";

$handle = fopen("http://$domain","r");

//$contents = stream_get_contents($handle);

$contents = '';

while (!feof($handle)) {

$contents .= fread($handle, 8192);

}

//var_dump($contents);

}

?></p>

<html>

<head>

<title>HTML Source Code Viewer</title>

</head>

<body></p>

<h2>

HTML Source Code Viewer

</h2></p>

<form method="post" name="pageform" action="htl.php" onsubmit="return validate(this);"></p>

<table border="0" style="border-collapse: collapse" width="">

<tr>

<td width="" height="91" valign="top">

<table style="border-collapse: collapse" width="" class="tooltop" height="76"></p>

<tr>

<td>

<table border="0" style="border-collapse: collapse" width="" cellspacing="5">

<tr>

<td height="28" width="100"><font size="2"><b>View source of</b></font><b><font size="2">:

</font></b></td>

<td height="28" width="">

 

<?php

echo"

<font size=1>http://</font><input type=text name='domain' size='26' value=></td>";

?>

<td height="28" width="">

<input type="submit" name="submit" value="View!" style="float: left"></td>

</tr>

<tr>

<td width="" height="21"> </td>

<td width="" colspan="2" height="21" valign="top"><font size="1">(eg. chapagain.com.np)</font></td></p>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

<?php

if(isset($_POST['submit']))

{

?>

<tr>

<td>

<textarea rows="10" cols="60" name="code"><?=$contents?></textarea>

</td>

</tr>

<?php

}

?>

</table>

</form>

<script language="JavaScript">

function validate(theform) {

if (theform.domain.value == "") { alert("No Domain"); return false; }

return true;

}

</script>

 

</body>

</html>

-------------------------------------------------------

 

 

 

if anyone knows the problem plz help me out

 

Link to comment
https://forums.phpfreaks.com/topic/175917-warining-in-fopen/
Share on other sites

hemi9,

 

You might try this PHP function at http://bit.ly/2gtz4g it is a very versatile and robust screen scrapper function written in PHP. It detects and uses cURL if available or uses standard file streams if wrappers are enabled.  It will also send proper headers to targets to simulate a valid browser help increase reliability.

Link to comment
https://forums.phpfreaks.com/topic/175917-warining-in-fopen/#findComment-927011
Share on other sites

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.