DotDotDash Posted February 11, 2009 Share Posted February 11, 2009 Hello, I have a slight problem with the script I am trying to create in PHP. Whilst I'm not inept I can't seem to troubleshoot this problem at all. I am not sure if it is to do with my configuration file or whatnot but it isn't working anyway. This is what I'm trying to do: <?php $newurl = 'www.fhdhgfhecjshdsh.com'; function check_url($url) { $fp = fsockopen($url, 80, $errno, $errstr, 30); if(!$fp) { return false; } fclose($fp); return true; } if(!check_url($newurl)) { echo 'That website could not be found.'; } else { echo 'That website exists.'; } ?> Now all this returns to me is that it exists... like below That website exists. Why does this happen? We all know that the fake url I have put up the top does NOT exist. For reference I am using Apache on my own computer with allow_url_fopen turned On. Any recommendations? Hope to hear from you all soon, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/144819-solved-validating-website-exists-problem/ Share on other sites More sharing options...
Maq Posted February 11, 2009 Share Posted February 11, 2009 Works for me. I get some warning when the website doesn't exist but when it does I get the correct output with zero errors/warnings. Quote Link to comment https://forums.phpfreaks.com/topic/144819-solved-validating-website-exists-problem/#findComment-759930 Share on other sites More sharing options...
DotDotDash Posted February 11, 2009 Author Share Posted February 11, 2009 Works for me. I get some warning when the website doesn't exist but when it does I get the correct output with zero errors/warnings. Hmmm, quite a pain. What exactly do you need to configure in your PHP ini file aside from the allow_url_fopen one? Could anything outwith PHP affect it? Quote Link to comment https://forums.phpfreaks.com/topic/144819-solved-validating-website-exists-problem/#findComment-759934 Share on other sites More sharing options...
killah Posted February 11, 2009 Share Posted February 11, 2009 Are you trying to see if the domain exist's or online and exist's? Quote Link to comment https://forums.phpfreaks.com/topic/144819-solved-validating-website-exists-problem/#findComment-759952 Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2009 Share Posted February 11, 2009 Is this your own server so that you know that the fsockopen() function has not been disabled in php.ini? Does a phpinfo() statement show any disabled functions? Is error_reporting set to E_ALL and display_errors set to ON so that you see all php generated errors? Quote Link to comment https://forums.phpfreaks.com/topic/144819-solved-validating-website-exists-problem/#findComment-759954 Share on other sites More sharing options...
DotDotDash Posted February 11, 2009 Author Share Posted February 11, 2009 Is this your own server so that you know that the fsockopen() function has not been disabled in php.ini? Does a phpinfo() statement show any disabled functions? Is error_reporting set to E_ALL and display_errors set to ON so that you see all php generated errors? All of them appear to be turned on and I have even added error_reporting(E_ALL) at the top of the file for extra measure. It just simply keeps validating ridiculous links with no warning or errors. Quote Link to comment https://forums.phpfreaks.com/topic/144819-solved-validating-website-exists-problem/#findComment-759972 Share on other sites More sharing options...
DotDotDash Posted February 11, 2009 Author Share Posted February 11, 2009 I actually figured the problem out. It is because I am using OpenDNS. When OpenDNS can't reach a webpage because it doesn't exist or is down then it redirects to a search page therefore fopensock doesn't know if it failed or not and puts through it as succeeded. Thanks for everyones feedback however! Quote Link to comment https://forums.phpfreaks.com/topic/144819-solved-validating-website-exists-problem/#findComment-760065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.