Ptsface12 Posted December 14, 2011 Share Posted December 14, 2011 Hello, I'm currently working on a gaming website, however there is an issue. I have a custom YouTube player, however I need to get the link dependant on a value from the database. The ID is in the URL, which is then collecting the youtube video URL from the database. However, I'm trying to then echo that back out into the Javascript video. On my normal page, that plays the Video is: Header: Styles.css & youTubeEmbed-jquery-1.0.css need to be added. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Having Fun With YouTube's API - Making a Custom Video Player | Tutorialzine Demo</title> <link rel="stylesheet" type="text/css" href="styles.css" /> <link rel="stylesheet" type="text/css" href="video_player/youTubeEmbed/youTubeEmbed-jquery-1.0.css" /> </head> Footer: All of that needs to be added. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="jquery.swfobject.1-1-1.min.js"></script> <script src="youTubeEmbed/youTubeEmbed-jquery-1.0.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#player').youTubeEmbed("VID LINK FROM DB SHOULD BE HERE"); $('form').submit(function(){ $('#player').youTubeEmbed({ video : 'VID LINK FROM DB SHOULD BE HERE', width : 640, // Height is calculated automatically progressBar : false // Hide the progress bar }); }); }); </script> </body> </html> <?php include("config.php"); $host = $config['Site']['Host']; $username = $config['Site']['Username']; $password = $config['Site']['Password']; $database = $config['Site']['Database']; $name = $config['Site']['Name']; $favicon = $config['Site']['Favicon']; mysql_connect($host, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); function getVid() { $vID = $_GET['vID']; $sQuery = "SELECT * FROM vids WHERE id='$vID'"; $sResult = mysql_query($sQuery); while($row = mysql_fetch_array($sResult)) { $vID = $row['url']; } } ?> Above is the Global.php, and that's where the problem lies, whenever I try to insert the peices required, nothing happens and the video doesn't show. Could anybody please help?! Quote Link to comment https://forums.phpfreaks.com/topic/253183-javascript-php/ Share on other sites More sharing options...
Ptsface12 Posted December 15, 2011 Author Share Posted December 15, 2011 Anybody? Really need to get this done. Quote Link to comment https://forums.phpfreaks.com/topic/253183-javascript-php/#findComment-1298215 Share on other sites More sharing options...
xyph Posted December 15, 2011 Share Posted December 15, 2011 Since I don't see 'echo' anywhere in that code, I'm just going to assume you haven't tried to echo anything. Quote Link to comment https://forums.phpfreaks.com/topic/253183-javascript-php/#findComment-1298224 Share on other sites More sharing options...
Ptsface12 Posted December 15, 2011 Author Share Posted December 15, 2011 Indeed I do, but it doesn't work, however I will insert what I have so far. (Not working!) <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="styles.css" /> <link rel="stylesheet" type="text/css" href="video_player/youTubeEmbed/youTubeEmbed-jquery-1.0.css" /> </head> <?php include("config.php"); $host = $config['Site']['Host']; $username = $config['Site']['Username']; $password = $config['Site']['Password']; $database = $config['Site']['Database']; $name = $config['Site']['Name']; $favicon = $config['Site']['Favicon']; mysql_connect($host, $username, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); function getVid() { $vID = $_GET['vID']; $sQuery = "SELECT * FROM vids WHERE id='$vID'"; $sResult = mysql_query($sQuery); while($row = mysql_fetch_array($sResult)) { global $vName, $vURL, $vDesc; $vURL = $row['url']; $vName = $row['title']; $vDesc = $row['description']; } } ?> <div id=\"player\" align=\"center\"> </div> </body> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="jquery.swfobject.1-1-1.min.js"></script> <script src="youTubeEmbed/youTubeEmbed-jquery-1.0.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#player').youTubeEmbed("http://www.youtube.com/watch?v=P1HGQQxmnP4"); $('form').submit(function(){ $('#player').youTubeEmbed({ video : 'http://www.youtube.com/watch?v=P1HGQQxmnP4', width : 640, // Height is calculated automatically progressBar : false // Hide the progress bar }); }); }); </script> </body> </html> Here are the instructions given by the document with the flash player: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Having Fun With YouTube's API - Making a Custom Video Player | Tutorialzine Demo</title> <link rel="stylesheet" type="text/css" href="styles.css" /> <link rel="stylesheet" type="text/css" href="youTubeEmbed/youTubeEmbed-jquery-1.0.css" /> </head> <body> <h1>Making a Custom YouTube Video Player</h1> <h2><a href="http://tutorialzine.com/2010/07/youtube-api-custom-player-jquery-css/">Back to Tutorialzine »</a></h2> <div id="page"> <p>This is a demo for Tutorialzine's Youtube API tutorial, in which we show you how to use YouTube's APIs, to create a custom CSS player for YouTube videos in a form of a jQuery plugin. Embedding videos in your website has never been easier. Just run the following code:</p> <pre>$('#element').youTubeEmbed('http://www.youtube.com/watch?v=u1zgFlCw8Aw'); // Or: $('#element').youTubeEmbed({ video : 'http://www.youtube.com/watch?v=u1zgFlCw8Aw', width : 600, // Height is calculated automatically progressBar : false // Hide the progress bar }); </pre> <p>The plugin uses YouTube's chromeless player, which allows you to build your own player controls. Changing the play/pause buttons or the progress bar is as easy as changing a couple of CSS values.</p> <blockquote> <p>To test the plugin, fill in a YouTube Video URL in the textbox below and hit "Embed".</p> <form action=""> <fieldset> <input type="text" id="url" /> <input type="submit" id="submitButton" value="Embed" /> <small>(if embedding has been disabled on the video, it will not show up)</small> </fieldset> </form> </blockquote> <div id="player"></div> </div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script src="jquery.swfobject.1-1-1.min.js"></script> <script src="youTubeEmbed/youTubeEmbed-jquery-1.0.js"></script> <script src="script.js"></script> </body> </html> (Script JS is the <script type="text/javascript"> at the bottom!) Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/253183-javascript-php/#findComment-1298233 Share on other sites More sharing options...
xyph Posted December 15, 2011 Share Posted December 15, 2011 Again, I don't see you using echo anywhere in your code. On another note, you should avoid using the global keyword. http://tjhunt.blogspot.com/2009/04/php-global-variables-are-not.html On another note, what happens when page.php?vID=' OR 1=1 is called? On another note, why do you declare the funtion 'getVid' ? It has no reusable code, and isn't ever called itself? Quote Link to comment https://forums.phpfreaks.com/topic/253183-javascript-php/#findComment-1298240 Share on other sites More sharing options...
Ptsface12 Posted December 15, 2011 Author Share Posted December 15, 2011 Hey, I'm not quite sure what you mean about the declaring getVid. Also, what am I exactly supposed to echo? >.< Im just trying to learn PHP, but at 14, I find it quite hard to know how to securely code and fix my faults. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/253183-javascript-php/#findComment-1298243 Share on other sites More sharing options...
xyph Posted December 15, 2011 Share Posted December 15, 2011 Age has nothing to do with this. You're trying to use the language, not learn it. There are plenty of introductory tutorials on the web that will help you. Maybe get your parent's to grab you a good PHP book for whichever winter gift-giving event you celebrate. At this point, you're asking us to tell you what value to use without giving us any values. We simply know what you want to do, and that the data you need is stored in a MySQL database with at least 3 columns. Quote Link to comment https://forums.phpfreaks.com/topic/253183-javascript-php/#findComment-1298250 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.