Jump to content

getting an extra %22 either side of the get url


madspof

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.