[thelist] PHP deleting a file

Matthias Willerich matthias at die-legendaeren.de
Wed Oct 12 06:54:40 CDT 2005


jeremy,

you're doing the same thing twice. It compares the 2 strings and they don't
seem to be the same. Maybe your $oldfile filename needs some convincing, did
you do all the stripslashes, trim and maybe strtolower as well? Are you sure
there's no linebreak or other hidden character? You checked the charset?

To debug this function, simply overwrite $oldfile, such as:

$oldphoto = "nophoto.gif"; //I c&p'd it from the if-statement, just taking
off the ! and you should do the same.

if ($oldphoto != "nophoto.gif") {
    // Delete the agents existing photo
    @unlink("$oldphoto");
  }

if THAT still deletes the file, then it's spooky. Otherwise your strings,
although they might look right, simply aren't the same.

cheers,
Matthias




More information about the thelist mailing list