hellonoko Posted October 1, 2008 Share Posted October 1, 2008 My below code uses a bit of Flash to create a mini mp3 player button for each mp3 in a directory. As it stands there are 3 test files in the directory but for some reason only the first flash player button is displayed and not the name of the file. So for some reason the loop is failing after the embedded flash. Any ideas? <?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>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/ Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 Variables are not interpolated within single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655139 Share on other sites More sharing options...
hellonoko Posted October 1, 2008 Author Share Posted October 1, 2008 So the double quotes within single quotes is wrong and i should concatenate instead? Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655144 Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 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\">"; Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655148 Share on other sites More sharing options...
DeanWhitehouse Posted October 1, 2008 Share Posted October 1, 2008 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.'"/>'; I think that's what thorpe meant. Edit: Or not Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655149 Share on other sites More sharing options...
hellonoko Posted October 1, 2008 Author Share Posted October 1, 2008 thorpe. your version returns: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home2/sharingi/public_html/REPOSITORY/filelist3.php on line 32 blade that is what i also though he meant but that did not work either. Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655176 Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 There is no syntax error in my code, maybe something you have prior to it. Post what you have. Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655182 Share on other sites More sharing options...
hellonoko Posted October 1, 2008 Author Share Posted October 1, 2008 full code: <?php $arr = array(); foreach (glob("*.*") as $filename) { $arr[$filename] = filemtime($filename); //echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>"; } /// //asort($arr); //echo "<br>"; //foreach($arr as $key => $value) //{ // echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>"; //} /// 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>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655185 Share on other sites More sharing options...
trq Posted October 1, 2008 Share Posted October 1, 2008 If your going to have double quotes within double quotes they need to be escaped like I posted in my example. Otherwise simply use single quotes within the double quoted string. Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655189 Share on other sites More sharing options...
hellonoko Posted October 1, 2008 Author Share Posted October 1, 2008 Escaped the quotes and does not have any errors but still only displays one song. And not the first one. www.sharingizcaring.com/REPOSITORY/filelist3.php <?php $arr = array(); foreach (glob("*.*") as $filename) { $arr[$filename] = filemtime($filename); //echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>"; } /// //asort($arr); //echo "<br>"; //foreach($arr as $key => $value) //{ // echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>"; //} /// 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>"; } } ?> Tried it with soft quotes on the outside '<object..... And that does not break the loop but breaks the Flash. That is how it is now. Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655192 Share on other sites More sharing options...
DeanWhitehouse Posted October 1, 2008 Share Posted October 1, 2008 maybe change foreach($arr as $key => $value) to foreach($arr as $key) or not? Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655207 Share on other sites More sharing options...
hellonoko Posted October 1, 2008 Author Share Posted October 1, 2008 Blade. Tried it but it just lists numbers now. The part of the script that displays a list of files works fine. It just when I add in the flash music player functionality that it fails. Quote Link to comment https://forums.phpfreaks.com/topic/126665-embedding-flash-in-php/#findComment-655208 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.