Re: Validating a link in php

From: Date: Fri, 26 Jan 2007 05:31:51 +0000
Subject: Re: Validating a link in php
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-247807@lists.php.net to get a copy of this message
Frank Arensmeier wrote: >Did you take a look at the error numbers / messages returned by >fsockopen? What do they say? Actually, I only get warnings, not errors, but here's what they say: Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/je/jefflynnesongs.com/jlvids/jlvids.php on line 98 Warning: fsockopen(): unable to connect to www.youtube.com/v/JqO8ZevPJNk:80 in /var/www/html/je/jefflynnesongs.com/jlvids/jlvids.php on line 98 >Another thing that poped up in my mind - curl. Tried that? Hmmm... I just did some experimenting and it looks promising. Here's the code that appears to work: $ch = curl_init("http://www.youtube.com/v/JqO8ZevPJNk"); if (curl_exec($ch)) //Do stuff for a valid URL else //Do stuff for an invalid URL Many thanks! I'm loving PHP, but I've got a lot to learn. Robert

« previous php.general (#247807) next »