Beth,

> When fopen successfully opens a file it populates an array
> $http_response_header, which you can examine to see if the link works or
> not - I don't believe you can actually get the file itself, but since
> that's not what we're after that's not a problem!

I noticed this reference to "$http_response_header" and straightaway quizzed
the manual, only to find that the only references to it (eg file open) lead
nowhere. Have gone through a few other pages, looking to see if I might
happen upon some detail, but failed. Sadly you don't refer to it in the code
snippet provided (below). Any code I've attempted blindly has
failed/reported errors.

Please point me in the right direction (otherwise I guess it'll be time to
download the new v4.3.0-RC and risk the bleeding edge - which according to
the manual does something different anyway...)
=dn



> Having said that, fopen produces a very annoying error if it doesn't
> find the page, but I found the following works:
>
> <?php
>
>     $SQL = "SELECT linkurl, linkID FROM links";
>     $result = mysql_query($SQL);
>
>     while($linkdata = mysql_fetch_array($result)){
>
>         $fp = fopen($linkdata['linkurl'],"r");
>         if($fp)
>         {
>             echo "<p>".$linkdata['linkurl']." is still valid.</p>";
>
>         }else{
>
>         echo "<p>".$linkdata['linkurl']." is invalid. Updating
> database... ";
>
>             $SQL = "UPDATE links SET status = 0 WHERE linkID =
> '".$linkdata['linkID']."'";
>                 $result2 = mysql_query($SQL);
>             if($result2)
>                 {
>                     echo "Database updated</p>";
>                 }
>         }
>
>     }
> ?>
>
> Rather than deleting the link, it's probably better to set a flag to
> show it was invalid last time you checked, but check it again next time.
> Or you could keep a count of the  number of failed attempts, and delete
> if it goes beyond 3 or so.
>
> Not sure how to supress the warning message that PHP automatically does
> when you haven't got a valid URL though.
>
> Hope this works for you!
>
> Beth Gore
> --
> http://bethanoia.dyndns.org
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to