1

So I'm making an attempt to remove links from the database, both image path and video link. I have given each type of file a code, 5 for videos, 2 and 1 for images. I have the following if statement to account for it:

if($mCode = 2 || $mCode = 1){
    unlink($mLoc); // delete image from directory
}

For my video link, however, which has an mCode of 5, whenever i try to remove it, it removes the file, but I get this warning:

Warning: unlink(test): No such file or directory

Why is it still passing through the if statement? Or how could I prevent this?

verdeletg
  • 15
  • 4

1 Answers1

3

With a single = you will set the $mCode. Use == for loose validation Use === for strict validation (includes the datatype validation)

if($mCode == 2 || $mCode == 1){
    unlink($mLoc); // delete image from directory
}
Wesley Abbenhuis
  • 692
  • 13
  • 19