I don't know if it is simple or not, but here we go...
I am calling a PHP script from the Flash and it works fine...
I have two places in Flash that calls this PHP script with different arguments at each time...
The thing is that I am giving out the argument-1 at the first time I call the PHP script, and the argument-2 at the second time with FMX's LoadVars() object...
The PHP script executes and returns the data just fine with the correct value of argument-1 when it is first executed...
The second time I execute the PHP script with different argument, argument-2, PHP gets it as its previous argument value,argument-1, even I executed the PHP script with the new argument, argument-2...
And if I execute the PHP script AGAIN with the argument-2, I get the correct result...
Does anybody know why???
In Flash, I have this script...
_level0.listDirectory("d:\\inetpub\\wwwroot\\Templates\\");
function listDirectory(currentDir)
{
showConnectMessage();
listDirLVs = new LoadVars();
listDirLVs.userDir = currentDir;
listDirLVs.sendAndLoad("http://localhost/ListDirectory.php", listDirLVs, "POST");
listDirLVs.onLoad = function(success)
{
if (success)
{
wholeDirArray = this.userDir.split("^");
temp = this.userDir;
for (i = 0 ; i < wholeDirArray.length ; i++)
{
fileArray[i] = wholeDirArray[i].split("|");
dirArray[i] = fileArray[i][fileArray[i].length - 1];
}
dirArray.splice(dirArray.length - 1, 1)
clearConnectMessage();
}
}
}
and PHP script is...
<?php
function GetFileList($path, &$a)
{
$d = array();
$f = array();
$nd = 0;
$nf = 0;
$hndl = opendir($path);
while($file = readdir($hndl))
{
if ($file == '.' || $file == '..')
continue;
if (is_dir($path.'\'.$file))
$d[$nd++] = $file;
else
$f[$nf++] = $file;
}
closedir($hndl);
sort($d);
sort($f);
$n = 1;
for ($i = 0 ; $i < count($d) ; $i++)
{
GetFileList($path.'\'.$d[$i].'\', $a[$n]);
print "$d[$i]^";
$a[$n++][0] = $d[$i];
}
for ($i = 0 ; $i < count($f) ; $i++)
{
print "$f[$i]|";
$a[$n++] = $f[$i];
}
}
function ShowFileList(&$a, $N)
{
$fileList = "";
for ($i = 1 ; $i < count($a) ; $i++)
{
if (is_array($a[$i]))
{
// echo "<H".$N.">".$a[$i][0]."</H".$N.">\n";
ShowFileList($a[$i], $N+1);
}
else
{
// echo "<Normal>".$a[$i]."</Normal>\n";
}
}
}
print "userDir=";
chdir($userDir);
GetFileList("$userDir", $array);
ShowFileList($array, 1);
?>
Oh... I didn't really write this PHP code... It basically came from PHP manual...
Can someone take a look at the code and see what I am doing wrong??? Thank you...
Jason