immunity Posted May 25, 2007 Share Posted May 25, 2007 How i can do it ? if i echo the embed whole (with address to ) its work fine (althought i dont want it!) but if i put the url in a variable it doesnt work like this : <?php $s = "http://www.youtube.com/watch?v=_i2MSvaZeqw"; echo "<object type=\"application/x-shockwave-flash\" style=\"width:425px; height:350px;\" data=\"".$s."\"><param name=\"movie\" value=\"".$s."\" /></object>" ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/ Share on other sites More sharing options...
chigley Posted May 25, 2007 Share Posted May 25, 2007 <?php echo "<object type=\"application/x-shockwave-flash\" style=\"width:425px; height:350px;\" data=\"$s\"><param name=\"movie\" value=\"$s\" /></object>" ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261670 Share on other sites More sharing options...
immunity Posted May 25, 2007 Author Share Posted May 25, 2007 it's created a parsing error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/other/db2student/labdb219/public_html/asdf.php on line 20 line 20 is the echo"code for embedding youtube"; do i have to do something on $s? Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261684 Share on other sites More sharing options...
chigley Posted May 25, 2007 Share Posted May 25, 2007 Paste more code please? Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261685 Share on other sites More sharing options...
immunity Posted May 25, 2007 Author Share Posted May 25, 2007 <?php $con = mysql_connect("localhost","labdb2_19","2004040"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("labdb2_19", $con); $sql = "SELECT youtube FROM movie WHERE title ='Spider-man3'"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"$row['youtube']\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"$row['youtube']\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"></embed></object> "; } mysql_free_result($result); mysql_close($con); ?> its the whole code in the page (nothing else) result from putty http://195.251.111.53/~labdb219/putty.JPG Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261689 Share on other sites More sharing options...
chigley Posted May 25, 2007 Share Posted May 25, 2007 <?php $con = mysql_connect("localhost","labdb2_19","2004040"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("labdb2_19", $con) or die(mysql_error()); $sql = "SELECT youtube FROM movie WHERE title ='Spider-man3'"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"$row['youtube']\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"$row['youtube']\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"></embed></object>"; } mysql_free_result($result); mysql_close($con); ?> Added a bit of debugging. Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261692 Share on other sites More sharing options...
immunity Posted May 25, 2007 Author Share Posted May 25, 2007 Added a bit of debugging. What that means ? what did u change Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261697 Share on other sites More sharing options...
chigley Posted May 25, 2007 Share Posted May 25, 2007 Run it and post any errors. Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261699 Share on other sites More sharing options...
immunity Posted May 25, 2007 Author Share Posted May 25, 2007 still the same :/ error Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/other/db2student/labdb219/public_html/asdf.php on line 20 Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261702 Share on other sites More sharing options...
chigley Posted May 25, 2007 Share Posted May 25, 2007 Silly me. Didn't spot that you missed out your final } brace! <?php $con = mysql_connect("localhost","labdb2_19","2004040"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("labdb2_19", $con) or die(mysql_error()); $sql = "SELECT youtube FROM movie WHERE title ='Spider-man3'"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo "<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"$row['youtube']\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"$row['youtube']\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"></embed></object>"; } mysql_free_result($result); mysql_close($con); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261706 Share on other sites More sharing options...
immunity Posted May 25, 2007 Author Share Posted May 25, 2007 same problem but i think you are wrong about brace } in your code there are 3 } and 2 { in my code its 2 } and 2 { Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261708 Share on other sites More sharing options...
chigley Posted May 25, 2007 Share Posted May 25, 2007 Sorry: long day! My bad. Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261711 Share on other sites More sharing options...
immunity Posted May 25, 2007 Author Share Posted May 25, 2007 no need to be sorry i am greatful that you even try to help Quote Link to comment https://forums.phpfreaks.com/topic/52976-embedding-youtube-video-via-php/#findComment-261714 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.