natasha23 Posted March 23, 2010 Share Posted March 23, 2010 Hi i am having trouble getting a you tube video to play. I have a form with a drop down menu and depending what option the user selects i want a different video to play. I am doing this via an if statement. But it doesnt run and it is printing out "no video available" before the user clicks on the submit button on the form. Can anyone tell me where i making mistakes please??? if ($shape == "circle" && $colour == "red") { echo "<A href='http://www.youtube.com/watch?v=8RHbBe-lvrc?'</A>"; } echo "No video Available"; Quote Link to comment Share on other sites More sharing options...
schilly Posted March 23, 2010 Share Posted March 23, 2010 your anchor tag isn't closed. other than that the code looks fine. can you post more of the code? please wrap it in the php reply tag too. Quote Link to comment Share on other sites More sharing options...
Catfish Posted March 23, 2010 Share Posted March 23, 2010 that snippet of code will definitely output "No video Available", and MAY output a link to a video if the conditions are met. I don't see how it relates to what you are talking about really. Quote Link to comment Share on other sites More sharing options...
-Karl- Posted March 23, 2010 Share Posted March 23, 2010 if ($shape == "circle" && $colour == "red") { echo "<A href='http://www.youtube.com/watch?v=8RHbBe-lvrc?'</A>"; } else { echo "No video Available"; } Then sort out your anchor. Quote Link to comment Share on other sites More sharing options...
natasha23 Posted March 24, 2010 Author Share Posted March 24, 2010 ok i re adjusted my code. I wanted it to only strat once the submit button is pressed. But it still doesn't work, anyone got any ideas? echo "<form name=shape test method=post>// this is my form where the user picks a color <Select NAME=$color> <Option>red</option> <Option>blue</option> </Select><input type='submit' name='Mix' value='Mix' /> </form>"; if (isset($_POST['submit'])) { if ($shape == "circle" && $color == "red") { $url = "http://www.youtube.com/"; $content = file_get_contents($url); echo $content; } else { echo "No video Available"; } } //Shape is chosen by the user from whatever shape they clicked on in previous page. I have tested shape with: echo $shape and it prints out circle Quote Link to comment Share on other sites More sharing options...
schilly Posted March 24, 2010 Share Posted March 24, 2010 i dont see how getting the contents of a youtube page is going to play the video. you probably want to look at the youtube embed code: <object width="480" height="385"> <param name="movie" value="http://www.youtube.com/v/4RriC_GnIIE&hl=en_US&fs=1&"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/4RriC_GnIIE&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed> </object> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.