hellonoko Posted October 5, 2008 Share Posted October 5, 2008 My below code displays a list of mp3s in a directory each with a mini mp3 player to listen to it. Depending on how I work the quotes for it either only the first flash music player shows up. Or all the songs shows up but the flash players are broken. Any suggestions? <?php $arr = array(); foreach (glob("*.*") as $filename) { $arr[$filename] = filemtime($filename); } arsort($arr); echo "<br>"; foreach($arr as $key => $value) { if ( $key !== "filelist3.php") { echo '<object type=\"application/x-shockwave-flash\" data=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\" width=\"17\" height=\"17\">'; echo '<param name=\"movie\" value=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\"/>'; echo '<img src=\"noflash.gif\" width=\"17\" height=\"17\" alt=\"\" />'; echo "$key<br>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/127139-embeded-flash-inside-loop-failing/ Share on other sites More sharing options...
DarkWater Posted October 5, 2008 Share Posted October 5, 2008 That's because variables aren't interpolated in single quotes. You'll need to use double quotes on the string and make sure to escape any other double quotes, or use sprintf() or break out of the PHP block and then just reenter for variables. Link to comment https://forums.phpfreaks.com/topic/127139-embeded-flash-inside-loop-failing/#findComment-657668 Share on other sites More sharing options...
hellonoko Posted October 5, 2008 Author Share Posted October 5, 2008 sprintf() does not do anything. when i un-escape my quotes it fails. sprintf( "<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key" width="17" height="17">"); sprintf( "<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key"/>"); sprintf( "<img src="noflash.gif" width="17" height="17" alt="" />"); sprintf( "$key<br>"); Link to comment https://forums.phpfreaks.com/topic/127139-embeded-flash-inside-loop-failing/#findComment-657692 Share on other sites More sharing options...
DarkWater Posted October 5, 2008 Share Posted October 5, 2008 When I say to use sprintf(), I mean to actually look up how to use it and use it properly. printf('<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/%s" width="17" height="17">', (string) $key); printf('<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/%s"/>', (string) $key); echo '<img src="noflash.gif" width="17" height="17" alt="" />'; echo "$key<br>"; Link to comment https://forums.phpfreaks.com/topic/127139-embeded-flash-inside-loop-failing/#findComment-657697 Share on other sites More sharing options...
hellonoko Posted October 5, 2008 Author Share Posted October 5, 2008 Ahh. I see how it works now but it still only works for one processing of the loop and does not display the file name http://www.sharingizcaring.com/filelist3.php Link to comment https://forums.phpfreaks.com/topic/127139-embeded-flash-inside-loop-failing/#findComment-657702 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.