Jump to content

PHP value in youtube link?


Dubbeldam

Recommended Posts

<object width="290" height="190"><param name="movie" value="<?php echo $_SESSION['SESS_FAVORITEYOUTUBE']?>?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<?php $_SESSION['SESS_FAVORITEYOUTUBE']?>fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="290" height="190" VSPACE="5px" HSPACE="5px" ></embed></object>

Apparently that does not work =(. the $_SESSION['SESS_FAVORITEYOUTUBE'] contains the youtube link. Anyone have any ideas how to make it work?

Link to comment
Share on other sites

Sorry for my newbyness, but I'm not sure what you mean by the actual HTML code

<!--#########################YOUTUBE#########################--><div class="transboxyoutube"><object width="290" height="190"><param name="movie" value="<?php $_SESSION['SESS_FAVORITEYOUTUBE']?>?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="<?php $_SESSION['SESS_FAVORITEYOUTUBE']?>?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="290" height="190" VSPACE="5px" HSPACE="5px" ></embed></object></div></html>

Basically, what I need to know is. How to get an external value such as $favoriteyoutube into the embedded youtube code & let it play the video.

Link to comment
Share on other sites

Pull the page up in a browser and view the source from the browser. The point is to figure out the actual code you're sending to the browser so you can figure out why the browser isn't doing what you think it should be. I'm not interested in the PHP code that produces the HTML, I want to see the actual HTML that the browser is receiving.

Link to comment
Share on other sites

Darnit! I figured out whats wrong. In the embedded code the link is:http://www.youtube.com/watch?v=9M3grQwyvLkIn the normal link the code is:http://www.youtube.com/watch?v=9M3grQwyvLkIs it possible to convert the normal link into the embedded one? I think thats rather hard as you have to remove www.youtube.com/watch?v=, and than add http://www.youtube.com/v/I have to think about this lol. For now I'll just use the video IDThanks for the help anyway!

Link to comment
Share on other sites

You can use parse_url to get the parts of a URL in order to rebuild it. http://www.php.net/manual/en/function.parse-url.phpYou can use that to extract the query string, and then use parse_str to break the query string up into an array variable/value pairs, like $_POST or $_GET:http://www.php.net/manual/en/function.parse-str.php

$url = 'http://www.youtube.com/watch?v=9M3grQwyvLk';$url_chunks = parse_url($url);$new_url = $url_chunks['scheme'] . '://' . $url_chunks['host'] . '/v/';$path_vars = array();parse_str($url_chunks['query'], $path_vars);if (isset($path_vars['v']))  $new_url .= $v;echo $new_url;

That uses the same scheme and host, so if the link starts as something like https://us.youtube.com/ then that will be in the converted URL also.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...