Warning: fsockopen() [function.fsockopen]: unable to connect

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Warning: fsockopen() [function.fsockopen]: unable to connect

Post by psychotomus »

I am trying to check if my link is on someones website before adding there link to my website. I get the following error's

Warning: fsockopen() [function.fsockopen]: unable to connect to http://www.thenarutommorpg.com:80 (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?) in /mounted-storage/home60b/sub001/sc18478-RGIJ/thenarutommorpg.com/links.php on line 27

Warning: feof(): supplied argument is not a valid stream resource in /mounted-storage/home60b/sub001/sc18478-RGIJ/thenarutommorpg.com/links.php on line 28

Code: Select all

if(isset($_POST['Submit']))
{
 
    $title = $_POST['textTitle'];
    $url = $_POST['textURL'];
    $descr = $_POST['textDESC'];
    $return = $_POST['textURL2'];
    $fp = fsockopen($return, 80, $errno, $errstr, 30);
    while (!feof($fp))
    {
        $page .= fgets($fp, 128);
    }
    if(stristr($page, '<a href="http://www.thenarutommorpg.com"') === TRUE) 
    {
        $sql = "INSERT INTO links (url, title, descr, return_url) VALUES ('$url', '$title', '$descr', '$return')";
        
        if (!($result = $db->sql_query($sql)))
        {
            message_die(GENERAL_ERROR, 'Could not insert link information', '', __LINE__, __FILE__, $sql);
        }
        
        $template->assign_vars(array('MESSAGE' => "Your Link has been added."));
    }
    else
    {
        $template->assign_vars(array('MESSAGE' => "Our link could not be found on the page you supplied; therefor, your link was not added."));
    }
 
}
Last edited by psychotomus on Sun Apr 13, 2008 9:15 pm, edited 1 time in total.
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Re: Warning: fsockopen() [function.fsockopen]: unable to connect

Post by psychotomus »

still need help with this.. ;\
psychotomus
Forum Contributor
Posts: 487
Joined: Fri Jul 11, 2003 1:59 am

Re: Warning: fsockopen() [function.fsockopen]: unable to connect

Post by psychotomus »

still looking for help on this 2month old topic. is there alternative way to do what I want to do or how can I remove those errors?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Warning: fsockopen() [function.fsockopen]: unable to connect

Post by Chris Corbyn »

You don't put the http:// portion in fsockopen(). The socket doesn't care about the protocol; you need to worry about that yourself. All it wants is the server name and a port number.
Post Reply