Cyber-Drugs
asked on
Calling a Function from a String - error
Hi guys,
I have this:
$param = "../foldera/folderb";
delete_recursive_dirs($par am);
delete_recursive_dirs() - is a function which deletes a folder and all it's contents.
When I run the code above, it throws an error, but when I run it like this:
delete_recursive_dirs("../ foldera/fo lderb");
it works perfectly...
Any ideas on what I need to do for this to work?
Cheers!
I have this:
$param = "../foldera/folderb";
delete_recursive_dirs($par
delete_recursive_dirs() - is a function which deletes a folder and all it's contents.
When I run the code above, it throws an error, but when I run it like this:
delete_recursive_dirs("../
it works perfectly...
Any ideas on what I need to do for this to work?
Cheers!
ASKER
Unfortunately, it doesn't...
Anything I can try?
Anything I can try?
Using echo to display debug data.
echo '<div>'.$params.'</div>';
And possibly edit delete_recursive_dir to show debug data as well.
-r-
echo '<div>'.$params.'</div>';
And possibly edit delete_recursive_dir to show debug data as well.
-r-
ASKER
Tried that, doesn't work,
URL I call:
mypage.php?function=cb_del etecase&pa ram='../De velopment/ OwcClientF iles/19/1/ 1/61/358'
and here's my code if it helps?
<html>
<head>
<?php
function delete_recursive_dirs($dir name)
{
// recursive function to delete
// all subdirectories and contents:
if(is_dir($dirname))$dir_h andle=open dir($dirna me);
while($file=readdir($dir_h andle))
{
if($file!="." && $file!="..")
{
if(!is_dir($dirname.DIRECT ORY_SEPARA TOR.$file) )
unlink ($dirname.DIRECTORY_SEPARA TOR.$file) ;
else delete_recursive_dirs($dir name.DIREC TORY_SEPAR ATOR.$file );
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
$function = $_GET['function'];
$param = stripslashes($_GET['param' ]);
if ($function != "") {
$background = 'orange';
} else {
$background = 'green';
}
switch($function) {
case "cb_deletecase":
$background = 'blue';
$url = delete_recursive_dirs($par am);
break;
}
?>
</head>
<body bgcolor='<?php echo $background; ?>'>
<?php
echo "delete_recursive_dirs(".$ param.")\n ";
echo "\t".$_SERVER['SCRIPT_NAME ']."\n";
echo "\t".$url."\n";
?>
</body>
</html>
and this is the full error:
<html>
<head>
<br />
<b>Warning</b>: readdir(): supplied argument is not a valid Directory resource in <b>C:\Program Files\xampp\htdocs\Develop ment\FuncC all.php</b > on line <b>9</b><br />
<br />
<b>Warning</b>: closedir(): supplied argument is not a valid Directory resource in <b>C:\Program Files\xampp\htdocs\Develop ment\FuncC all.php</b > on line <b>18</b><br />
<br />
<b>Warning</b>: rmdir('../Development/OwcC lientFiles /19/1/1/61 /358') [<a href='function.rmdir'>func tion.rmdir </a>]: No such file or directory in <b>C:\Program Files\xampp\htdocs\Develop ment\FuncC all.php</b > on line <b>19</b><br />
</head>
<body bgcolor='blue'>
delete_recursive_dirs('../ Developmen t/OwcClien tFiles/19/ 1/1/61/358 ')
/Development/FuncCall.php
1
</body>
</html>
URL I call:
mypage.php?function=cb_del
and here's my code if it helps?
<html>
<head>
<?php
function delete_recursive_dirs($dir
{
// recursive function to delete
// all subdirectories and contents:
if(is_dir($dirname))$dir_h
while($file=readdir($dir_h
{
if($file!="." && $file!="..")
{
if(!is_dir($dirname.DIRECT
unlink ($dirname.DIRECTORY_SEPARA
else delete_recursive_dirs($dir
}
}
closedir($dir_handle);
rmdir($dirname);
return true;
}
$function = $_GET['function'];
$param = stripslashes($_GET['param'
if ($function != "") {
$background = 'orange';
} else {
$background = 'green';
}
switch($function) {
case "cb_deletecase":
$background = 'blue';
$url = delete_recursive_dirs($par
break;
}
?>
</head>
<body bgcolor='<?php echo $background; ?>'>
<?php
echo "delete_recursive_dirs(".$
echo "\t".$_SERVER['SCRIPT_NAME
echo "\t".$url."\n";
?>
</body>
</html>
and this is the full error:
<html>
<head>
<br />
<b>Warning</b>: readdir(): supplied argument is not a valid Directory resource in <b>C:\Program Files\xampp\htdocs\Develop
<br />
<b>Warning</b>: closedir(): supplied argument is not a valid Directory resource in <b>C:\Program Files\xampp\htdocs\Develop
<br />
<b>Warning</b>: rmdir('../Development/OwcC
</head>
<body bgcolor='blue'>
delete_recursive_dirs('../
/Development/FuncCall.php
1
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
DOH!!!
Works perfectly now, cheers Roonaan! :)
Works perfectly now, cheers Roonaan! :)
-r-