Forum Moderators: coopster

Message Too Old, No Replies

Using fsockopen()

How to disallow warning message

         

henry0

1:48 pm on Oct 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



While using fsockopen(), to check a URL using:

$fp = fsockopen("$url", 80, $errno, $errstr, 30);
if (!$fp)
{
echo "<br>The Link (URL) could ot be validated<br>
<b>You entered: $url</b><p>
<a href=\"../auth/user_edit.php\">Please try again</a><p>";
exit();
}
else
{
// then it was successful!
fclose($fp); // and carry on
}

It does the job as expected
My message is displayed but also the following warning:

Warning: fsockopen() [function.fsockopen]: unable to connect to [asdfghjkl.com:80...] (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in C:\wamp\www\aaaaa\url\links\submit_url.php on line 106

The rest (my message) is fine and required:

The Link (URL) could ot be validated
You entered: [asdfghjkl.com...]
Please try again
I don’t mind the warning message but do not want to show directory construction for the error might be triggered by some hack
Anyway to get rid of that message?

eelixduppy

1:51 pm on Oct 9, 2006 (gmt 0)



Why not just use error suppression?:

$fp = @fsockopen("$url", 80, $errno, $errstr, 30);

henry0

2:02 pm on Oct 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks
Shame on me! I should think twice before posting :)

mcavic

3:23 pm on Oct 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It doesn't make sense to use a url with fsockopen, because it opens raw connections, not Web pages. Passing www.whatever.com to it instead of [whatever.com...] will avoid the error, but it will still report another error if the site doesn't exist.

henry0

3:51 pm on Oct 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK this makes sense; so I will just trim it
thanks