Validating a link in php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I'm hoping y'all can help me with a bit of a php code problem I'm having.

What I'm trying to do is link to YouTube videos (more than one in a single
webpage).  However, because I'm worried about the videos going away and the
links going bad, I'd like to use PHP to check if the link is good; if it's
good, display the video link, else display a static image that I have on my
servers.

Where I'm having troubles is in the checking of whether the url is good.  I
think part of the problem is YouTube itself.  I've tried file() and
fsockopen(), but neither seem to work.

Below is an example of the block of code I'm trying to write.

<?
   error_reporting(E_ALL ^ E_NOTICE);
   if (the "http://www.youtube.com/v/JqO8ZevPJNk"; url is valid) <-- ???
   {
     echo "      <object height=\"400\" width=\"475\">\n";
     echo "      <param name=\"movie\" value=\"http://www.youtube.com/v/JqO8ZevPJNk\";>\n";
     echo "      <embed src=\"http://www.youtube.com/v/JqO8ZevPJNk\"\n";;
     echo "         type=\"application/x-shockwave-flash\" height=\"400\" width=\"475\">\n";
     echo "      </object>\n";
   }
   else
   {
     echo "      <a href=\"10538overturevideo.jpg\"><img SRC=\"10538overturevideo.jpg\" height=\"130\"></a>\n";
   }
?>

Many thanks for any assistance you can provide.

Robert Porter

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux