Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    June 8th, 2005
    Posts
    68
    What's wrong with my URL validation script?
    I've got a url validation script but I can't get it to work. When the script checks the urls it returns HTTP code of 400 which is a bad request?

    When all the links should be getting a HTTP code of 200.

    What's wrong with my script. Here's the function code that I use:

    PHP Code:
     function check_url ($url) {
    $url_pieces=parse_url($url);
    $path=($url_pieces['path']) ? $url_pieces['path'] : "/";
    $port=($url_pieces['port']) ? $url_pieces['port'] : 80;

    if (
    $fp fsockopen($url_pieces['host'], $port, &$errno, &$errstr5)) {
    fputs($fp"HEAD $path HTTP/1.1\r\n\r\n");
    fputs($fp"HOST:$url_pieces[host]\r\n");
    fputs($fp"CONNECTION:close\r\n\r\n");

    $data=fgets($fp,128);
    fclose($fp);
    $array=explode(" "$data);
    return 
    $array[1];
    } else {
    return 
    "$errstr($errno)";
    }


  2. #2
    Member YetAnotherAffiliate's Avatar
    Join Date
    October 28th, 2005
    Location
    Ohio
    Posts
    48
    &$errno, &$errstr

    ????

    New to php, but Im working on it...
    If I had a server set up with php
    to debug the script Id help you out... sorry...

  3. #3
    Member
    Join Date
    June 8th, 2005
    Posts
    68
    *bump*

    Anybody can help me? Or does anyone of any URL validation script in PHP available online? Thanks.

  4. #4
    Not Verif-Lidated infoTim's Avatar
    Join Date
    January 18th, 2005
    Location
    Sunny Florida
    Posts
    1,021
    There's an extra \r\n where you have the HEAD request.

    You can debug this sort of thing using 'telnet <host> 80' and type the things out yourself.

    The HEAD is ok, but then the HOST: line gets treated as a new request and that's coughing up the 400 error you see.
    Tim
    consultant by day, affiliate by night

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Junk sites linking to your site with wrong URL (404 Errors in GWT)
    By kse in forum Search Engine Optimization
    Replies: 16
    Last Post: April 24th, 2012, 10:33 AM
  2. PHP Pulling Wrong Page Url in Wordpress
    By tiger625 in forum GoldenCAN
    Replies: 2
    Last Post: October 10th, 2009, 04:44 PM
  3. Validation Sing-Along
    By Rhea in forum Rakuten LinkShare - LS
    Replies: 1
    Last Post: May 21st, 2005, 11:19 PM
  4. test purchase: wrong sale amount, therefore wrong commission
    By hungirl in forum Commission Junction - CJ
    Replies: 19
    Last Post: December 6th, 2004, 04:07 AM
  5. Please Suggest a Good url Redirect Script
    By snakebaby in forum Programming / Datafeeds / Tools
    Replies: 17
    Last Post: February 2nd, 2004, 10:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •