richard_PHP Posted June 13, 2012 Share Posted June 13, 2012 Hello all, Using a database backend and the WHILE function I'm wanting all YouTube videos entered in said database to show up in one loop. Simples. However, coded it's deciding that it does not want to play ball. Code: <?php // Start the connection to the database $conn = mysql_pconnect("****", "******", "*****"); // Select the database to use mysql_select_db("*****", $conn); // Create the MySQL command to retrieve all records $sql = "SELECT * FROM videos"; $result = mysql_query($sql, $conn); while ($array = mysql_fetch_array($result)) { $title = $array[title]; $hlink = $array[hlink]; $desc = $array[description]; echo "<h2>$title</h2>"; echo "<iframe width='560' height='315' src='$hlink' frameborder='0' allowfullscreen></iframe>"; echo "<p>$desc</p><hr />"; } ?> The YouTube embed is in an echo line with the link to the video (eg: 'http://www.youtube.com/*****') in variable '$hlink'. I've tried \" instead of single quotes and it still isn't working. Hopefully someone can help. Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/264121-youtube-embed-help/ Share on other sites More sharing options...
thara Posted June 13, 2012 Share Posted June 13, 2012 At first I showed this from your code. $title = $array[title]; $hlink = $array[hlink]; $desc = $array[description]; Strings in the square brackets need to be within single quotes. $title = $array['title']; $hlink = $array['hlink']; $desc = $array['description']; Quote Link to comment https://forums.phpfreaks.com/topic/264121-youtube-embed-help/#findComment-1353542 Share on other sites More sharing options...
Pikachu2000 Posted June 13, 2012 Share Posted June 13, 2012 Maybe you explain just what about it "isn't working"? Quote Link to comment https://forums.phpfreaks.com/topic/264121-youtube-embed-help/#findComment-1353543 Share on other sites More sharing options...
richard_PHP Posted June 13, 2012 Author Share Posted June 13, 2012 FAO thara: Changed that but it's still not working FAO Pikachu2000: The webpage displays as normal but the YouTube embedded player (and thus video) don't show at all. Quote Link to comment https://forums.phpfreaks.com/topic/264121-youtube-embed-help/#findComment-1353550 Share on other sites More sharing options...
thara Posted June 13, 2012 Share Posted June 13, 2012 show us your $hlink data Quote Link to comment https://forums.phpfreaks.com/topic/264121-youtube-embed-help/#findComment-1353553 Share on other sites More sharing options...
richard_PHP Posted June 13, 2012 Author Share Posted June 13, 2012 Nevermind! I've got it working! Thanks all anyway! Quote Link to comment https://forums.phpfreaks.com/topic/264121-youtube-embed-help/#findComment-1353555 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.