Jump to content

Recommended Posts

i have made and eddited a script so it will will list the folders in one place and also make a link the link needs to be something like this audio2.php?directory=ramdom with the ramdom being the variable set by this script the only problem is i am getting this audio2.php?directory=%22ramdom%22 with unwanted %22 on the end and the beggening. Can anyone help me ?

<?php


function listSubFolders ($dir, $level=0) {
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir("$dir/$file")) {
                    $indent = str_repeat('---', $level);
                    echo "<a href=audio2.php?directory=\"$file\">$indent $file</a>" . "<br>";
                    listSubFolders("$dir/$file", $level+1);  // list subfolders of this folder
                }
            }
        }
        closedir($handle);
    }
}

$dir = "./music";  // <-- specify folder

listSubFolders($dir);
?>
Your're adding quotes into the url where you're not supposed to:
echo "<a href=audio2.php?directory=[color=red]\"$file\"[/color]>$indent $file</a>"
The offedning code is highlighted in red.

Use this instead:
[code=php:0]echo '<a href=a"udio2.php?directory=' . $file . '>' . $indent . ' ' . $file . "<a/><br />\n";[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.