Jump to content

embeded flash inside loop failing


hellonoko

Recommended Posts

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

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.

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>");

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>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.