Jump to content

Recommended Posts

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!

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?

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?

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.

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.