Re: fopen to validate a URL
| From: | Kenneth R Zink II | Date: | Thu, 15 Mar 2001 21:58:13 +0000 |
| Subject: | Re: fopen to validate a URL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-44140@lists.php.net to get a copy of this message | ||
Well I changed the code to this expecting a true or false response (1 or 0)
$url=$row[url];
echo "Old URL = ".$url."<br>";
$fp = fopen("$url","r");
echo "fp = ".$fp."<br>"; //Debug line to see what $fp is returning
switch ($fp){
case 1:
echo "Valid URL<br>";
break;
case 0:
echo "URL IS NOT VALID<br>";
$url="http://";
break;
}
echo "New URL = ".$url."<br>";
I get this as a responce on a URL I know is valid (I tested it in my
browser)
Old URL = http://www.warrenbowley.com
Warning: fopen("http://www.warrenbowley.com","r")
- Bad file descriptor in
/var/www2/html/members/datacopy.php on line 73
fp =
URL IS NOT VALID
New URL = http://
Kenneth R Zink II Hellcat1@S-Series.Org ICQ# 5095094
'87 2.8L TBI GMC S-15 Ext. Cab (Hurricane) ...524 in the works !!!
http://www.s-series.org/htm/windstorm/project-windstorm.htm
'85 3.4L Carbed Chevy S-10 Blazer (FireStorm) ...Soon to be 3.4L SFI DIS !!!
http://www.s-series.org/htm/firestorm/firestorm.htm
Racing by the Grace of God!!
> on 3/15/01 04:39 PM, Hellcat1@EV1.Net splat open and thusly melted:
>
> > $url=$row[url];
> >
> > echo "Old URL = ".$url."<br>";
> >
> > $fp = @fopen($url,"r");
> > if ($fp){
> > echo "Valid URL<br>";
> > }else{
> > echo "URL IS NOT VALID";
> > $url="http://";
> > }
> >
> > echo "New URL = ".$url."<br>";
>
> what exactly do you expect to happen, and what actually happens? i have a
> feeling, based on your code, that your $url is missing the
> "http://" part,
> and the script is failing because of that.