Adding a $embed to a video embed code.

Discussion in 'PHP' started by jonnythirkill, Nov 9, 2008.

  1. #1
    Hey,

    I am trying to allow the users of my website to embed youtube videos by only providing the link. I need it so that if no link is provided that the rest of the embed code is not displayed. I have limited PHP knowledge and im seeking help. The site runs on wordpress.

    This is what ive got so far:

    <?php  $embed = $value = get_post_meta($post->ID, "embed", true); if ($embed == NULL) { echo ''; } else { echo '<object width="425" height="344"><param name="movie" value="$embed&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="$embed=en&fs=1&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>'; } ?>
    PHP:


    I do not understand how to add the $embed inside the code. If anyone could help me it would be greatly appreciated.

    Thanks,

    Jonny
     
    jonnythirkill, Nov 9, 2008 IP
  2. keiths

    keiths Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Without seeing all of your code I'm not positive but I think this is what you are trying to do

    <?php
    $embed = get_post_meta($post->ID, "embed", true); 
    if ($embed == NULL) {
    	echo ''; 
    } else { 
    	echo '<object width="425" height="344"><param name="movie" value="$embed&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="$embed=en&fs=1&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>'
    ; } 
    ?>
    PHP:
     
    keiths, Nov 9, 2008 IP
  3. jonnythirkill

    jonnythirkill Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You have cleaned it up but you missed the bit I need help with :p

    You see the "<object width=...>"? Where it says "Value=" I was trying to put the $embed so it displays the link from the "get_post_meta..."

    Hope that makes it clearer.

    Thanks,

    Jonny
     
    jonnythirkill, Nov 10, 2008 IP