RE: [PHP] fopen to validate a URL

From: Date: Thu, 15 Mar 2001 22:01:13 +0000
Subject: RE: [PHP] fopen to validate a URL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-44141@lists.php.net to get a copy of this message
try @fopen(...) prepending a '@' to the mysql funcs will suppress error messages by those functions... maybe it'll work for fopen also. never tried it, though. > -----Original Message----- > From: Kenneth R Zink II [mailto:Hellcat1@EV1.Net] > Sent: Thursday, March 15, 2001 4:58 PM > To: PHP > Subject: Re: [PHP] fopen to validate a URL > > > 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. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#44141) next »