Confused by unlink problem!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 3A Web Hosting

    Confused by unlink problem!

    Hi Folks

    I'm trying to delete a file.

    unlink('../images/photos/1967_GT_500_She lby_Mustang.jpg ');
    That works

    $fm = "../images/photos/1967_GT_500_She lby_Mustang.jpg ";
    unlink($fm);
    That doesn't. Why?

    I need to pass the file name as a variable as it's the result of a mysql
    query.

    --
    Colin

    3A Web Hosting Team

  • Ian.H

    #2
    Re: Confused by unlink problem!

    On Sun, 04 Jan 2004 21:36:43 +0000, 3A Web Hosting wrote:
    [color=blue]
    > Hi Folks
    >
    > I'm trying to delete a file.
    >
    > unlink('../images/photos/1967_GT_500_She lby_Mustang.jpg '); That works
    >
    > $fm = "../images/photos/1967_GT_500_She lby_Mustang.jpg "; unlink($fm);
    > That doesn't. Why?
    >
    > I need to pass the file name as a variable as it's the result of a mysql
    > query.[/color]


    What error do you get Colin? I've just finished a project that does
    exactly that (actually concatenated string of vars) with no problems.



    Regards,

    Ian

    --
    Ian.H [Design & Development]
    digiServ Network - Web solutions
    www.digiserv.net | irc.digiserv.ne t | forum.digiserv. net
    Programming, Web design, development & hosting.

    Comment

    • 3A Web Hosting

      #3
      Re: Confused by unlink problem!

      Hi Ian
      [color=blue]
      > What error do you get Colin? I've just finished a project that does
      > exactly that (actually concatenated string of vars) with no problems.[/color]

      I get :-

      Warning: unlink(../images/photos/1967_GT_500_She lby_Mustang.jpg ): No
      such file or directory in
      /var/www/html/gallery/admin/killphotos.php on line 87

      The file is definately there. It get's deleted without problem if I use
      the path instead of a variable.
      --
      Colin

      3A Web Hosting Team

      Comment

      • CountScubula

        #4
        Re: Confused by unlink problem!

        "3A Web Hosting" <info@3awebhost ing.co.uk> wrote in message
        news:3FF89874.3 E1283C6@3awebho sting.co.uk...[color=blue]
        > Hi Ian
        >[color=green]
        > > What error do you get Colin? I've just finished a project that does
        > > exactly that (actually concatenated string of vars) with no problems.[/color]
        >
        > I get :-
        >
        > Warning: unlink(../images/photos/1967_GT_500_She lby_Mustang.jpg ): No
        > such file or directory in
        > /var/www/html/gallery/admin/killphotos.php on line 87
        >
        > The file is definately there. It get's deleted without problem if I use
        > the path instead of a variable.
        > --
        > Colin
        >
        > 3A Web Hosting Team
        > http://www.3awebhosting.co.uk[/color]

        Ok, I know this is weird,

        but do another action on the variable, such as

        print "file :$fm:\n";
        print "size:".filesiz e($fm)."\n";

        just to see if it breaks in other functions as well.

        --
        Mike Bradley
        http://www.gzentools.com -- free online php tools


        Comment

        • 3A Web Hosting

          #5
          Re: Confused by unlink problem!

          Hi
          [color=blue]
          > Ok, I know this is weird,
          >
          > but do another action on the variable, such as
          >
          > print "file :$fm:\n";
          > print "size:".filesiz e($fm)."\n";
          >
          > just to see if it breaks in other functions as well.[/color]

          Just tried that. I get the following:-

          file :../images/photos/1967_GT_500_She lby_Mustang.jpg :
          Warning: filesize(): Stat failed for
          .../images/photos/1967_GT_500_She lby_Mustang.jpg (errno=2 - No such file
          or
          directory) in /var/www/html/gallery/admin/killphotos.php on line 82
          size:

          --
          Colin

          3A Web Hosting Team

          Comment

          • 3A Web Hosting

            #6
            Re: Confused by unlink problem!

            Hi

            Well, I've just tried running it on a different server and it worked.
            Weird!

            --
            Colin

            3A Web Hosting Team

            Comment

            • CountScubula

              #7
              Re: Confused by unlink problem!

              "3A Web Hosting" <info@3awebhost ing.co.uk> wrote in message
              news:3FF8BBD3.C 6846E37@3awebho sting.co.uk...[color=blue]
              > Hi
              >
              > Well, I've just tried running it on a different server and it worked.
              > Weird!
              >
              > --
              > Colin
              >
              > 3A Web Hosting Team
              > http://www.3awebhosting.co.uk[/color]


              try the full path instead of the ../

              just a guess

              --
              Mike Bradley
              http://www.gzentools.com -- free online php tools


              Comment

              • Rahul Anand

                #8
                Re: Confused by unlink problem!

                It is perfectly fine to pass variable containing filename to *unlink*
                function.
                And it should work, look for error in filename (may be unnecessary
                space or some other char).

                --
                Rahul


                3A Web Hosting <info@3awebhost ing.co.uk> wrote in message news:<3FF8876B. 23C33108@3awebh osting.co.uk>.. .[color=blue]
                > Hi Folks
                >
                > I'm trying to delete a file.
                >
                > unlink('../images/photos/1967_GT_500_She lby_Mustang.jpg ');
                > That works
                >
                > $fm = "../images/photos/1967_GT_500_She lby_Mustang.jpg ";
                > unlink($fm);
                > That doesn't. Why?
                >
                > I need to pass the file name as a variable as it's the result of a mysql
                > query.[/color]

                Comment

                Working...