waynewex Posted September 18, 2008 Share Posted September 18, 2008 Hey guys. I'm creating a social network of my own in PHP and was wondering if there is anyway that I can allow users to specify a youtube URL (not the embed source) and have it show up on their profile? Quote Link to comment Share on other sites More sharing options...
dropfaith Posted September 18, 2008 Share Posted September 18, 2008 how are you doing this question seems vague if its really just including a link its submitted the same way as any other content you are letting users submit. then <a href="link">name</a> but im assuming you need something else Quote Link to comment Share on other sites More sharing options...
waynewex Posted September 18, 2008 Author Share Posted September 18, 2008 Well, I have this, but it doesn't seem to work? <object width="300" height="219"><param name="movie" value="<?php echo $user_details['youtube_video'];?>&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01"></param><param name="allowFullScreen" value="true"></param><embed src="<?php echo $user_details['youtube_video']; ?>&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowfullscreen="true" width="300" height="219"></embed></object> Quote Link to comment Share on other sites More sharing options...
dropfaith Posted September 18, 2008 Share Posted September 18, 2008 this should work you will need to edit the select to get the user details a little bit to make it fit your needs but this is the exact code i uset to pull playlists into flash players so it should work out <? // includes include("template/conf.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // generate and execute query $Id = mysql_escape_string($_GET['Id']); $query = "SELECT * FROM blog WHERE Id = '$Id'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // get resultset as object $row = mysql_fetch_object($result); // print details if ($row) { ?><object width="425" height="344"><param name="movie" value="<? echo $row->Blog; ?>"></param><param name="allowFullScreen" value="true"></param><embed src="<? echo $row->Blog; ?>" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object> <? } else { ?> <p> <font size="-1"> could not be located in our database.</font> <? } // close database connection mysql_close($connection); ?> Quote Link to comment Share on other sites More sharing options...
waynewex Posted September 18, 2008 Author Share Posted September 18, 2008 Okay, I've figured out the problem. The URL that is embedded in the object looks like: Whereas the URL of the video is: How can I subtract the string jVs9YANjbuM from ? Is there a specific method that you guys could recommend? Quote Link to comment Share on other sites More sharing options...
dropfaith Posted September 18, 2008 Share Posted September 18, 2008 you cant get rid of the v=jVs9YANjbuM thats what makes youtube select that video much like php?id=3 in php its the id value <object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/jVs9YANjbuM&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/jVs9YANjbuM&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object> Quote Link to comment Share on other sites More sharing options...
waynewex Posted September 18, 2008 Author Share Posted September 18, 2008 No you see, Is the URL that will be embedded in the source. Whereas Is the URL that Youtube gives you. So what I need to do is strip jVs9YANjbuM from and place the jVs9YANjbuM in like so: <object width="425" height="344"> <param name="movie" value="http://www.youtube.com/v/<?php echo subtracted_string; ?>&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01"></param> <param name="allowFullScreen" value="true"></param> <embed src="http://www.youtube.com/v/<?php echo subtracted_string; ?>&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object> Quote Link to comment Share on other sites More sharing options...
waynewex Posted September 18, 2008 Author Share Posted September 18, 2008 I have <?php $equalsign = strpos($user_details['youtube_video'],"="); $andsign = strpos($user_details['youtube_video'],"&"); ?> So far... I'm just wondering where to go from here? Is there a function that allows you to take a string out of another string by giving a start position and an end position? Quote Link to comment Share on other sites More sharing options...
dropfaith Posted September 18, 2008 Share Posted September 18, 2008 http://us2.php.net/str-pad but if users are getting the html link from youtube you wont need to strip it just do <object width="425" height="344"><param name="movie" value="<? echo $row->Blog; ?>&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="<? echo $row->Blog; ?>&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object> that ending string &hl=en&fs=1 can be left on the video command users will insert the url link to video and the remaining string will remain there should work out fine as from what ive seen that string doesnt change on the like 4 videos i just clicked on Quote Link to comment Share on other sites More sharing options...
waynewex Posted September 18, 2008 Author Share Posted September 18, 2008 It's okay: I do so like: <?php $equalsign = strpos($user_details['youtube_video'],"="); $get_val = substr($user_details['youtube_video'],$equalsign+1,11); ?> <div align="center"><br /> <object width="425" height="344"> <param name="movie" value="http://www.youtube.com/v/<?php echo $get_val; ?>&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01"> </param> <param name="allowFullScreen" value="true"></param> <embed src="http://www.youtube.com/v/<?php echo $get_val; ?>&hl=en&fs=1&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object> </div> 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.