Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 8th, 2006, 09:03 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem passing multiple arguments to php script

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="mp3player.swf?playlist=playlist3.php?Id[]=3&Id[]=7" />
  </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
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++;
      } 
}

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:
while($i = readdir($fdir)) {
   list($name, $ext) = explode('.', $i, 2);
   if(strtolower($ext) == 'mp3' && in_array($name, $_GET['Id'])){
         $playlist[$n] = $i;
         $n++;
      }
}

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
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++;
      } 
}

2th part:
while($i = readdir($fdir)) {
   list($name, $ext) = explode('.', $i, 2);
   if(strtolower($ext) == 'mp3' && in_array($name, $_GET['Id'])){
         $playlist[$n] = $i;
         $n++;
      }
}
// 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>";





?>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Declarative arguments passing between DetailsViews andremi Classic ASP Basics 1 May 10th, 2007 09:24 PM
Passing multiple arguments to function zarikiane XSLT 2 July 18th, 2006 09:35 AM
passing arguments to executables DaveG BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 0 May 30th, 2006 03:26 PM
Passing arguments to contructor of dynamically... jacob ASP.NET 1.0 and 1.1 Professional 3 December 2nd, 2005 02:43 PM
passing/getting arguments from ShellExecute TazMania23 Visual C++ 0 May 21st, 2004 12:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.