fsockopen commands

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Syl

    #1

    fsockopen commands

    Hi group - I have a database table with 4 columns that hold a url.

    I am selecting each url and I need to check to see if it is valid. I
    assumed I could use the fsockopen command. I've had to parse the url,
    since it cannot take the http://

    Here is my testing code :

    $query = 'select id, reg, lurl, lurl_f, burl, burl_f from srl
    where id = 862 order by id';
    $result = pg_query($query ) or die('Query failed: ' .
    pg_last_error() );
    $nrows = pg_numrows($res ult);

    if ($nrows != 0) {
    while ($line = pg_fetch_array( $result, null, PGSQL_ASSOC)) {
    $newurl=parse_u rl($line['lurl']);
    $newurl2 = $newurl[host].$newurl[path];

    $fp = fsockopen($newu rl2,80, $errno, $errstr, 30);
    if($fp) {
    echo '<p>'.$newurl2. ' is good.</p>';
    } else {
    echo '<p>'.$newurl2. ' is bad.</p>';
    }
    }

    My error is :

    Warning: fsockopen() [function.fsocko pen]: php_network_get addresses:
    getaddrinfo failed: Name or service not known in
    /data/web/public/alert.scc.ca/anne/regwatch_links. php on line 53

    Warning: fsockopen() [function.fsocko pen]: unable to connect to
    laws.justice.gc .ca/en/A-2/SOR-96-433/index.html:80 (Unknown error) in
    /data/web/public/alert.scc.ca/anne/regwatch_links. php on line 53

    laws.justice.gc .ca/en/A-2/SOR-96-433/index.html is invalid.

    Which is not true - since this *is* a valid URL.

    Any ideas ?

  • Andy Hassall

    #2
    Re: fsockopen commands

    On 1 Aug 2006 12:39:28 -0700, "Syl" <david.hunter@g mail.comwrote:
    >Warning: fsockopen() [function.fsocko pen]: php_network_get addresses:
    >getaddrinfo failed: Name or service not known in
    >/data/web/public/alert.scc.ca/anne/regwatch_links. php on line 53
    >
    >Warning: fsockopen() [function.fsocko pen]: unable to connect to
    >laws.justice.g c.ca/en/A-2/SOR-96-433/index.html:80 (Unknown error) in
    >/data/web/public/alert.scc.ca/anne/regwatch_links. php on line 53
    >
    >laws.justice.g c.ca/en/A-2/SOR-96-433/index.html is invalid.
    >
    >Which is not true - since this *is* a valid URL.
    A URL is not a valid host, so it makes no sense to pass it to fsockopen.

    If you want to check an HTTP URL, use an HTTP client - for example cURL, or
    the fopen_wrappers feature of PHP.

    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    Working...