I'm attempting to put my music collection on the web using PHP and I hit
a problem. When I attempt an opendir of a directory that contains a "'"
character the opendir fails. Here's the code snippet:
function GetAlbumArt ($path) {
if ($handle = opendir ("$path")) {
while (false !== ($element = readdir ($handle))) {
if (strpos ($element, "AlbumArt") == 0 &&
strpos ($element, "Large") != 0) {
return $element;
} // if
} // while
closedir ($handle);
} // if
} // GetAlbumArt
$path = "/web/Music/Rock/David Lee Roth/A Little Ain\'t Enough"
The error message I get on the page is:
*Warning*: opendir(/web/Music/Rock/David Lee Roth/A Little Ain\'t
Enough): failed to open dir: No such file or directory in
*/web/php/music.php* on line *6
*I guess I need to escape the "'" but it seems like it's already escaped
in the error message. How can I solve this problem?
--
Taxation with representation isn't so hot, either!*
*