/    Sign up×
Community /Pin to ProfileBookmark

Problem passing multiple arguments to php script

Hi all i have problem passing the [B]multiple arguments [/B] 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>[/CODE]

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][/CODE]

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][/CODE]

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

?>[/CODE]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Brooksie155Feb 08.2006 — Not sure if you can pass arrays of data using the url - however you could pass a delimited string:

playlist3.php?songs=first.mp3~second.mp3~third.mp3

Here I have used "~" as my delimiter, but anyhting will do as long as it will not appear in any of your data elements.
[code=php]
$Id = array()
$Id = explode('~',$_GET['songs']);
[/code]

This will leave you with an array assigned as follows:

$Id[0] = "first.mp3"

$Id[1] = "second.mp3"

$Id[2] = "third.mp3"
Copy linkTweet thisAlerts:
@methodauthorFeb 08.2006 — Not sure if you can pass arrays of data using the url - however you could pass a delimited string:

playlist3.php?songs=first.mp3~second.mp3~third.mp3

Here I have used "~" as my delimiter, but anyhting will do as long as it will not appear in any of your data elements.
[code=php]
$Id = array()
$Id = explode('~',$_GET['songs']);
[/code]

This will leave you with an array assigned as follows:

$Id[0] = "first.mp3"

$Id[1] = "second.mp3"

$Id[2] = "third.mp3"[/QUOTE]


Thank u for u reply. Actually i do not want to pass it like u did!!

i want to pass some thing like this which is without bracket:

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

currently if i remove bracket it will not play even ID=3 but if i use bracket It will play only Id=3 not Id=7!! Furthermore,currently i assumed that that songs inside mp3 are name as 1.mp3,2.mp3 which i do not like !! I want them to have any name .i hope some one help me with this.
×

Success!

Help @method spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...