Results 1 to 6 of 6

Thread: [RESOLVED] Something weird going on with is_file...

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Resolved [RESOLVED] Something weird going on with is_file...

    For an assignment we have to create a shopping cart. For some reason, this happens:

    Here's the code:
    PHP Code:
      $file_path=dirname(__FILE__) . "../images/products/" $_GET['picpath']; // It's just the file name here, such as foo.gif, or bar.jpg

      
    if (!is_file($file_path))
      {
        
    printf("Something went wrong (The file doesn't exist or is not writable: <b>" $file_path "</b>). Please remove it manually.");
      }

      if (
    is_file($file_path)) //file_exists() also works.
      
    {
        
    unlink($file_path);
      } 
    The result of this is strange. It prints that "something went wrong", then it removes the file any way? What's going on here? I have tried the same code with and without dirname(__FILE__), same result. I don't understand how it an IF can be TRUE and FALSE. Is it one of those things where you need like === or !== or something?

    You can be sure that this is the only code that has anything to do with testing for files etc.
    Last edited by Slyke; May 20th, 2009 at 05:46 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width