Re: Detection of missing links



"PHPeter" <me@xxxxxxxxxxx> wrote in
news:42e752e5$0$24474$ed2619ec@xxxxxxxxxxxxxxxxxxxxxxxxxx:

> I wonder if someone can help me?
>
> I have a table of records - in fact it is an index. Each record has a
> 'More' hyperlink which is supposed to take you to a more detailed
> information page - one for each entry.
>
> The 'More' hyperlink is displayed on the fly as the table is being
> displayed. It is going to take me some time to complete each detailed
> information page so I would like to have the 'More' hyperlink
> displayed only when a valid page has been written.
>
> Is there a way of detecting a missing URL to the detailed page so I
> can suppress the corresponding 'More' link?. This would avoid the
> 'Page Not Found' warning.

<?php

$test = join('', file('http://your.server.com/more123.html'));
if(eregi('not found', $test)){ //Test against a string in your 404 page
echo 'No details currently available.';
}
else{
echo "<a href='/more123.html'>More Details</a>";
}
?>

Just edit the URL that $test is looking up based upon wherever the
details link would point for that particular record. Make sure the eregi
() call is testing against a string that appears in your ErrorDocument
404.

hth


--

Bulworth : PHP/MySQL/Unix | Email : str_rot13('f@xxxxxxxx');
--------------------------|---------------------------------
<http://www.phplabs.com/> | PHP scripts, webmaster resources
.