NameSilo

[Resolved] How to fix infinite error looping?

Spaceship Spaceship
Watch

newsiness

VIP Member
Impact
49
How to fix infinite error looping?

This is a small portion of my php script which is as shown below:

PHP:
$fd = fopen($theDomain.$page, "r"); 
$value = "";
while(!feof($fd)){
	$value .= fread($fd, 4096);	
}
fclose($fd);

When the script fail to open the domain url, it returns me infinite error looping which you can refer to the snapshot below:
infinitejg9.png


Is there anyway, when the script sees the error it returns me like "Page not found" message?

Thanks in advance!!!
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
if (file_exists($thevar)) { 

$fd = fopen($theDomain.$page, "r"); 
$value = "";
while(!feof($fd)){
    $value .= fread($fd, 4096);    
}
fclose($fd);  
}

Should get you started ^^
 
1
•••
You can try this either :D Untested but should surpress the first error and return false on a 404 page.

PHP:
if( false !== ( $fd = @fopen($theDomain.$page, "r") ) )
{ 
   $value = "";
  while(!feof($fd)){
     $value .= fread($fd, 4096);    
  }
fclose($fd);
}
 
1
•••
Or simply

PHP:
if(  $fd = @fopen($theDomain.$page, "r")  )
{ 
   $value = "";
  while(!feof($fd)){
     $value .= fread($fd, 4096);    
  }
fclose($fd);
}

or simplier

PHP:
$value=file_get_contents($theDomain.$page);

On failure $value will be FALSE
 
1
•••
Danltn, baxter & elmister,

Thanks...it works!!!! :)
++Rep added.
 
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back