Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem passing multiple arguments to php script

Status
Not open for further replies.

keith23

Technical User
May 26, 2005
97
NL
Hi all i have problem passing the multiple arguments to a php script . I call a script like beleow:

mp3player.swf?playlist=playlist3.php?Id[]=3&Id[]=7

from :

main code:
Code:
<html>
<head>
<title>JW Flash MP3 Player</title>
</head>
<body>


 <object type="application/x-shockwave-flash" width="280" height="280"
    data="mp3player.swf?playlist=playlist.php?Id[]=5&Id[]=7">
  <param name="movie" value="[B]mp3player.swf?playlist=playlist3.php?Id[]=3&Id[]=7"[/B] />
  </object>


</body>
</html>


When i use the 1th part only which is in bold the scripts work fine and goes plays all songs from directory:

Code:
1th part
[B]while($i = readdir($fdir)) {
   // if a .mp3 string is found, add the file to the array
   if (strpos(strtolower($i),".mp3") !== false) {
  	   $playlist[$n] = $i;
  	   $n++;
  	} 
}[/B]


But when i remove 1th bold part and use 2th bold part it only plays for me the first song which is the first passed value but not the second passed value. Could any one help me what is wrong here ?Thanks

Code:
2th part:
[B]while($i = readdir($fdir)) {
   list($name, $ext) = explode('.', $i, 2);
   if(strtolower($ext) == 'mp3' && in_array($name, $_GET['Id'])){
         $playlist[$n] = $i;
         $n++;
      }
}[/B]


playlist3.php code with both bold part .When i run i use one of them each time
Code:
<?php




// setting the directory to search for mp3 files
$dir = "mp3/";



// reading the directory and inserting the mp3 files in the playlist array
$n = 0;
$playlist = array();
$fdir = opendir($dir);
1th part
[B]while($i = readdir($fdir)) {
   // if a .mp3 string is found, add the file to the array
   if (strpos(strtolower($i),".mp3") !== false) {
  	   $playlist[$n] = $i;
  	   $n++;
  	} 
}[/B]

2th part:
[B]while($i = readdir($fdir)) {
   list($name, $ext) = explode('.', $i, 2);
   if(strtolower($ext) == 'mp3' && in_array($name, $_GET['Id'])){
         $playlist[$n] = $i;
         $n++;
      }
}[/B]
// close the directory and sort the array
closedir($fdir);
//array_multisort($playlist);

//print_r($playlist);

// echoing the playlist to flash
echo "<player showDisplay=\"yes\" showPlaylist=\"no\" autoStart=\"yes\">\n";
for ($i=0; $i<sizeof($playlist); $i++) {
   // for the title it filters the directory and the .mp3 extension out
   echo "  <song path=\"$dir$playlist[$i]\" title=\"".str_replace(".mp3","",$playlist[$i])."\" />\n";
}
echo "</player>";





?>
 
Babyjeffy thank u for u reply. Now even Id[]=3 is does not get passed by remove ? from front of playlist3.php?

Is there a way to pass values without bracket and stop assuming the song in mp3 are named as 1.mp3,2.mp3... .I actually want them to have any name .I hope i get some help here.Thanks
 
Well... I haven't ever experienced someone using [] in the query string before (it may be possible - but I don't ever use anything like that).

Look at recoding your solution so that it doesn't require you send [] in your URL.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top