using fopen() in write mode is failing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cscorley@gmail.com

    using fopen() in write mode is failing

    For some reason, I cannot use fopen() on the file in write mode. The
    file "time" is in the same directory as the .php file, with
    permissions set to 0766.

    PHP Version 5.2.5
    Apache/2.2.8

    code snip in question:

    $file = "time";
    function updateParseTime ($name){
    global $file;
    if (file_exists($n ame) && file_exists($fi le)) {
    if(($fp = fopen($file,"wb "))){
    $lastmod = filemtime($name );
    if(!(fwrite($fp , $lastmod))){
    echo "cannot update time";
    }
    }
    else{
    echo "$file cannot be opened. \n";
    }
    }
    else{
    echo "$name or $file not found.";
    }
    }

    on the 4th line it fails the if check ($fp = fopen...) and just
    outputs "$file cannot be opened"

    Am I missing something?
  • Gordon

    #2
    Re: using fopen() in write mode is failing

    On May 30, 9:08 pm, cscor...@gmail. com wrote:
    For some reason, I cannot use fopen() on the file in write mode. The
    file "time" is in the same directory as the .php file, with
    permissions set to 0766.
    >
    PHP Version 5.2.5
    Apache/2.2.8
    >
    code snip in question:
    >
    $file = "time";
    function updateParseTime ($name){
            global $file;
            if (file_exists($n ame) && file_exists($fi le)) {
                    if(($fp = fopen($file,"wb "))){
                            $lastmod = filemtime($name );
                            if(!(fwrite($fp , $lastmod))){
                                    echo "cannot update time";
                            }
                    }
                    else{
                            echo "$file cannot be opened. \n";
                    }
            }
            else{
                    echo "$name or $file not found.";
            }
    >
    }
    >
    on the 4th line it fails the if check ($fp = fopen...) and just
    outputs "$file cannot be opened"
    >
    Am I missing something?
    Is error reporting on? If it is then PHP will echo out its own error
    message in addition to yours. Did you originally create the file
    you're trying to write to or was it created via a PHP script? If the
    former is the case then it will have you as the owner. PHP runs as the
    webserver's user (something like www or apache or nobody, assuming
    you're using PHP in a webserver environment). This will mean a
    permission denied error occurs when you try to open the file. Try
    setting the file to 666 chmod, or chown it to the Apache process's
    user.

    Comment

    • cscorley@gmail.com

      #3
      Re: using fopen() in write mode is failing

      On May 30, 3:13 pm, Gordon <gordon.mc...@n tlworld.comwrot e:
      On May 30, 9:08 pm, cscor...@gmail. com wrote:
      >
      >
      >
      For some reason, I cannot use fopen() on the file in write mode. The
      file "time" is in the same directory as the .php file, with
      permissions set to 0766.
      >
      PHP Version 5.2.5
      Apache/2.2.8
      >
      code snip in question:
      >
      $file = "time";
      function updateParseTime ($name){
      global $file;
      if (file_exists($n ame) && file_exists($fi le)) {
      if(($fp = fopen($file,"wb "))){
      $lastmod = filemtime($name );
      if(!(fwrite($fp , $lastmod))){
      echo "cannot update time";
      }
      }
      else{
      echo "$file cannot be opened. \n";
      }
      }
      else{
      echo "$name or $file not found.";
      }
      >
      }
      >
      on the 4th line it fails the if check ($fp = fopen...) and just
      outputs "$file cannot be opened"
      >
      Am I missing something?
      >
      Is error reporting on? If it is then PHP will echo out its own error
      message in addition to yours. Did you originally create the file
      you're trying to write to or was it created via a PHP script? If the
      former is the case then it will have you as the owner. PHP runs as the
      webserver's user (something like www or apache or nobody, assuming
      you're using PHP in a webserver environment). This will mean a
      permission denied error occurs when you try to open the file. Try
      setting the file to 666 chmod, or chown it to the Apache process's
      user.
      I 'touch'ed the file on the server itself, so yes its owned by my
      user. I've attempted to chown+chgrp the file to apache's, but it
      doesn't help at all. The file is already chmod'ed to 0766.

      After turning on error reporting, it outputs this:

      "Warning: fopen(time) [function.fopen]: failed to open stream:
      Permission denied in /var/www/html/xmlparser.php on line 53"

      with line 53 being the $fp = fopen().. line.

      Comment

      • Jerry Stuckle

        #4
        Re: using fopen() in write mode is failing

        cscorley@gmail. com wrote:
        On May 30, 3:13 pm, Gordon <gordon.mc...@n tlworld.comwrot e:
        >On May 30, 9:08 pm, cscor...@gmail. com wrote:
        >>
        >>
        >>
        >>For some reason, I cannot use fopen() on the file in write mode. The
        >>file "time" is in the same directory as the .php file, with
        >>permissions set to 0766.
        >>PHP Version 5.2.5
        >>Apache/2.2.8
        >>code snip in question:
        >>$file = "time";
        >>function updateParseTime ($name){
        >> global $file;
        >> if (file_exists($n ame) && file_exists($fi le)) {
        >> if(($fp = fopen($file,"wb "))){
        >> $lastmod = filemtime($name );
        >> if(!(fwrite($fp , $lastmod))){
        >> echo "cannot update time";
        >> }
        >> }
        >> else{
        >> echo "$file cannot be opened. \n";
        >> }
        >> }
        >> else{
        >> echo "$name or $file not found.";
        >> }
        >>}
        >>on the 4th line it fails the if check ($fp = fopen...) and just
        >>outputs "$file cannot be opened"
        >>Am I missing something?
        >Is error reporting on? If it is then PHP will echo out its own error
        >message in addition to yours. Did you originally create the file
        >you're trying to write to or was it created via a PHP script? If the
        >former is the case then it will have you as the owner. PHP runs as the
        >webserver's user (something like www or apache or nobody, assuming
        >you're using PHP in a webserver environment). This will mean a
        >permission denied error occurs when you try to open the file. Try
        >setting the file to 666 chmod, or chown it to the Apache process's
        >user.
        >
        I 'touch'ed the file on the server itself, so yes its owned by my
        user. I've attempted to chown+chgrp the file to apache's, but it
        doesn't help at all. The file is already chmod'ed to 0766.
        >
        After turning on error reporting, it outputs this:
        >
        "Warning: fopen(time) [function.fopen]: failed to open stream:
        Permission denied in /var/www/html/xmlparser.php on line 53"
        >
        with line 53 being the $fp = fopen().. line.
        What's in $file at the time you try to call fopen()? And why do you
        have the file set as executable by the owner?

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • cscorley@gmail.com

          #5
          Re: using fopen() in write mode is failing

          On May 30, 4:26 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          cscor...@gmail. com wrote:
          On May 30, 3:13 pm, Gordon <gordon.mc...@n tlworld.comwrot e:
          On May 30, 9:08 pm, cscor...@gmail. com wrote:
          >
          >For some reason, I cannot use fopen() on the file in write mode. The
          >file "time" is in the same directory as the .php file, with
          >permissions set to 0766.
          >PHP Version 5.2.5
          >Apache/2.2.8
          >code snip in question:
          >$file = "time";
          >function updateParseTime ($name){
          > global $file;
          > if (file_exists($n ame) && file_exists($fi le)) {
          > if(($fp = fopen($file,"wb "))){
          > $lastmod = filemtime($name );
          > if(!(fwrite($fp , $lastmod))){
          > echo "cannot update time";
          > }
          > }
          > else{
          > echo "$file cannot be opened. \n";
          > }
          > }
          > else{
          > echo "$name or $file not found.";
          > }
          >}
          >on the 4th line it fails the if check ($fp = fopen...) and just
          >outputs "$file cannot be opened"
          >Am I missing something?
          Is error reporting on? If it is then PHP will echo out its own error
          message in addition to yours. Did you originally create the file
          you're trying to write to or was it created via a PHP script? If the
          former is the case then it will have you as the owner. PHP runs as the
          webserver's user (something like www or apache or nobody, assuming
          you're using PHP in a webserver environment). This will mean a
          permission denied error occurs when you try to open the file. Try
          setting the file to 666 chmod, or chown it to the Apache process's
          user.
          >
          I 'touch'ed the file on the server itself, so yes its owned by my
          user. I've attempted to chown+chgrp the file to apache's, but it
          doesn't help at all. The file is already chmod'ed to 0766.
          >
          After turning on error reporting, it outputs this:
          >
          "Warning: fopen(time) [function.fopen]: failed to open stream:
          Permission denied in /var/www/html/xmlparser.php on line 53"
          >
          with line 53 being the $fp = fopen().. line.
          >
          What's in $file at the time you try to call fopen()? And why do you
          have the file set as executable by the owner?
          >
          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstuck...@attgl obal.net
          =============== ===
          The file named "time" is (sans quotations of course) in $file. The
          time file itself is blank.

          It was just set for rwx when I touched the file, so i just kept it and
          added write permissions to the file for other users. I've changed it
          to 0666 but it doesn't seem to affect anything.

          Comment

          • Rik Wasmus

            #6
            Re: using fopen() in write mode is failing

            On Sat, 31 May 2008 00:54:42 +0200, <cscorley@gmail .comwrote:
            On May 30, 4:26 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
            >cscor...@gmail .com wrote:
            On May 30, 3:13 pm, Gordon <gordon.mc...@n tlworld.comwrot e:
            >On May 30, 9:08 pm, cscor...@gmail. com wrote:
            >>
            >>For some reason, I cannot use fopen() on the file in write mode. The
            >>file "time" is in the same directory as the .php file, with
            >>permissions set to 0766.
            >>PHP Version 5.2.5
            >>Apache/2.2.8
            >>code snip in question:
            >>$file = "time";
            >>function updateParseTime ($name){
            >> global $file;
            >> if (file_exists($n ame) && file_exists($fi le)) {
            >> if(($fp = fopen($file,"wb "))){
            >> $lastmod = filemtime($name );
            >> if(!(fwrite($fp , $lastmod))){
            >> echo "cannot update time";
            >> }
            >> }
            >> else{
            >> echo "$file cannot be opened. \n";
            >> }
            >> }
            >> else{
            >> echo "$name or $file not found.";
            >> }
            >>}
            >>on the 4th line it fails the if check ($fp = fopen...) and just
            >>outputs "$file cannot be opened"
            >>Am I missing something?
            >Is error reporting on? If it is then PHP will echo out its own error
            >message in addition to yours. Did you originally create the file
            >you're trying to write to or was it created via a PHP script? If the
            >former is the case then it will have you as the owner. PHP runs as
            >the
            >webserver's user (something like www or apache or nobody, assuming
            >you're using PHP in a webserver environment). This will mean a
            >permission denied error occurs when you try to open the file. Try
            >setting the file to 666 chmod, or chown it to the Apache process's
            >user.
            >>
            I 'touch'ed the file on the server itself, so yes its owned by my
            user. I've attempted to chown+chgrp the file to apache's, but it
            doesn't help at all. The file is already chmod'ed to 0766.
            >>
            After turning on error reporting, it outputs this:
            >>
            "Warning: fopen(time) [function.fopen]: failed to open stream:
            Permission denied in /var/www/html/xmlparser.php on line 53"
            >>
            with line 53 being the $fp = fopen().. line.
            >>
            >What's in $file at the time you try to call fopen()? And why do you
            >have the file set as executable by the owner?
            >
            The file named "time" is (sans quotations of course) in $file. The
            time file itself is blank.
            >
            It was just set for rwx when I touched the file, so i just kept it and
            added write permissions to the file for other users. I've changed it
            to 0666 but it doesn't seem to affect anything.
            What is your getcwd()? Is it what you expect / the directory 'time' should
            be in?
            --
            Rik Wasmus
            ....spamrun finished

            Comment

            • lawrence k

              #7
              Re: using fopen() in write mode is failing

              On May 30, 4:08 pm, cscor...@gmail. com wrote:
              For some reason, I cannot use fopen() on the file in write mode. The
              file "time" is in the same directory as the .php file, with
              permissions set to 0766.
              >
              PHP Version 5.2.5
              Apache/2.2.8
              >
              code snip in question:
              >
              $file = "time";
              function updateParseTime ($name){
              global $file;
              if (file_exists($n ame) && file_exists($fi le)) {
              if(($fp = fopen($file,"wb "))){
              $lastmod = filemtime($name );
              if(!(fwrite($fp , $lastmod))){
              echo "cannot update time";
              }
              }
              else{
              echo "$file cannot be opened. \n";
              }
              }
              else{
              echo "$name or $file not found.";
              }
              >
              }
              >
              on the 4th line it fails the if check ($fp = fopen...) and just
              outputs "$file cannot be opened"
              >
              Am I missing something?

              A little off-topic, but your code is an example of the Arrow Anti-
              Pattern:




              Comment

              • lawrence k

                #8
                Re: using fopen() in write mode is failing

                On May 30, 4:08 pm, cscor...@gmail. com wrote:
                For some reason, I cannot use fopen() on the file in write mode. The
                file "time" is in the same directory as the .php file, with
                permissions set to 0766.
                >
                PHP Version 5.2.5
                Apache/2.2.8
                >
                code snip in question:
                >
                $file = "time";
                function updateParseTime ($name){
                global $file;
                if (file_exists($n ame) && file_exists($fi le)) {
                if(($fp = fopen($file,"wb "))){
                $lastmod = filemtime($name );
                if(!(fwrite($fp , $lastmod))){
                echo "cannot update time";
                }
                }
                else{
                echo "$file cannot be opened. \n";
                }
                }
                else{
                echo "$name or $file not found.";
                }
                >
                }
                >
                on the 4th line it fails the if check ($fp = fopen...) and just
                outputs "$file cannot be opened"
                >
                Am I missing something?

                If you chmod $file to 0777 does your script then work?

                Comment

                • cscorley@gmail.com

                  #9
                  Re: using fopen() in write mode is failing

                  On May 30, 6:02 pm, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
                  What is your getcwd()? Is it what you expect / the directory 'time' should
                  be in?
                  --
                  Rik Wasmus
                  ...spamrun finished
                  Yes, it returns the expected directory. Whenever I set the fopen to
                  use read mode, it gets into the if body fine.

                  On May 30, 9:59 pm, lawrence k <lkrub...@geoci ties.comwrote:
                  A little off-topic, but your code is an example of the Arrow Anti-
                  Pattern:
                  >

                  >
                  http://www.codinghorror.com/blog/archives/000486.html
                  Ah, I have a bad habit of that. I just write out what I think and
                  eventually get around to cleaning things up again once it works :]

                  On May 30, 10:17 pm, lawrence k <lkrub...@geoci ties.comwrote:
                  If you chmod $file to 0777 does your script then work?
                  No. All that does is add execute permissions to the file anyway.

                  Comment

                  • cscorley@gmail.com

                    #10
                    Re: using fopen() in write mode is failing

                    On May 30, 3:08 pm, cscor...@gmail. com wrote:
                    For some reason, I cannot use fopen() on the file in write mode. The
                    file "time" is in the same directory as the .php file, with
                    permissions set to 0766.
                    >
                    PHP Version 5.2.5
                    Apache/2.2.8
                    >
                    code snip in question:
                    >
                    $file = "time";
                    function updateParseTime ($name){
                    global $file;
                    if (file_exists($n ame) && file_exists($fi le)) {
                    if(($fp = fopen($file,"wb "))){
                    $lastmod = filemtime($name );
                    if(!(fwrite($fp , $lastmod))){
                    echo "cannot update time";
                    }
                    }
                    else{
                    echo "$file cannot be opened. \n";
                    }
                    }
                    else{
                    echo "$name or $file not found.";
                    }
                    >
                    }
                    >
                    on the 4th line it fails the if check ($fp = fopen...) and just
                    outputs "$file cannot be opened"
                    >
                    Am I missing something?
                    Actually, I think it must have something to do with the way this
                    particular webserver is setup (be it apache/php), because it works
                    fine when tested on another server (not maintained by me).

                    Comment

                    • Lawrence Krubner

                      #11
                      Re: using fopen() in write mode is failing

                      cscorley@gmail. com wrote:
                      On May 30, 3:08 pm, cscor...@gmail. com wrote:
                      >For some reason, I cannot use fopen() on the file in write mode. The
                      >file "time" is in the same directory as the .php file, with
                      >permissions set to 0766.
                      >>
                      >PHP Version 5.2.5
                      >Apache/2.2.8
                      >>
                      >code snip in question:
                      >>
                      >$file = "time";
                      >function updateParseTime ($name){
                      > global $file;
                      > if (file_exists($n ame) && file_exists($fi le)) {
                      > if(($fp = fopen($file,"wb "))){
                      > $lastmod = filemtime($name );
                      > if(!(fwrite($fp , $lastmod))){
                      > echo "cannot update time";
                      > }
                      > }
                      > else{
                      > echo "$file cannot be opened. \n";
                      > }
                      > }
                      > else{
                      > echo "$name or $file not found.";
                      > }
                      >>
                      >}
                      >>
                      >on the 4th line it fails the if check ($fp = fopen...) and just
                      >outputs "$file cannot be opened"
                      >>
                      >Am I missing something?
                      >
                      Actually, I think it must have something to do with the way this
                      particular webserver is setup (be it apache/php), because it works
                      fine when tested on another server (not maintained by me).

                      It's true. Is there any chance you've an older version of PHP installed,
                      some version from before the "b" flag was introduced? Have you tried:

                      fopen($file,"w" )

                      just to see what would happen?


                      Comment

                      • cscorley@gmail.com

                        #12
                        Re: using fopen() in write mode is failing

                        On May 31, 2:08 am, Lawrence Krubner <lawre...@krubn er.comwrote:
                        cscor...@gmail. com wrote:
                        On May 30, 3:08 pm, cscor...@gmail. com wrote:
                        For some reason, I cannot use fopen() on the file in write mode. The
                        file "time" is in the same directory as the .php file, with
                        permissions set to 0766.
                        >
                        PHP Version 5.2.5
                        Apache/2.2.8
                        >
                        code snip in question:
                        >
                        $file = "time";
                        function updateParseTime ($name){
                        global $file;
                        if (file_exists($n ame) && file_exists($fi le)) {
                        if(($fp = fopen($file,"wb "))){
                        $lastmod = filemtime($name );
                        if(!(fwrite($fp , $lastmod))){
                        echo "cannot update time";
                        }
                        }
                        else{
                        echo "$file cannot be opened. \n";
                        }
                        }
                        else{
                        echo "$name or $file not found.";
                        }
                        >
                        }
                        >
                        on the 4th line it fails the if check ($fp = fopen...) and just
                        outputs "$file cannot be opened"
                        >
                        Am I missing something?
                        >
                        Actually, I think it must have something to do with the way this
                        particular webserver is setup (be it apache/php), because it works
                        fine when tested on another server (not maintained by me).
                        >
                        It's true. Is there any chance you've an older version of PHP installed,
                        some version from before the "b" flag was introduced? Have you tried:
                        >
                        fopen($file,"w" )
                        >
                        just to see what would happen?
                        I've tried all modes that include writing options (r+, w+, a, etc),
                        and none of them seem to work. The PHP verion is 5.2.5, and reflects
                        that when I do phpinfo(). The server in question is Fedora9 with php/
                        apache installed via yum from the repos, and both have nearly default
                        settings.

                        Comment

                        • Gordon

                          #13
                          Re: using fopen() in write mode is failing

                          On May 31, 3:59 am, lawrence k <lkrub...@geoci ties.comwrote:
                          On May 30, 4:08 pm, cscor...@gmail. com wrote:
                          >
                          >
                          >
                          For some reason, I cannot use fopen() on the file in write mode. The
                          file "time" is in the same directory as the .php file, with
                          permissions set to 0766.
                          >
                          PHP Version 5.2.5
                          Apache/2.2.8
                          >
                          code snip in question:
                          >
                          $file = "time";
                          function updateParseTime ($name){
                                  global $file;
                                  if (file_exists($n ame) && file_exists($fi le)) {
                                          if(($fp = fopen($file,"wb "))){
                                                  $lastmod = filemtime($name );
                                                  if(!(fwrite($fp , $lastmod))){
                                                          echo "cannot update time";
                                                  }
                                          }
                                          else{
                                                  echo "$file cannot be opened. \n";
                                          }
                                  }
                                  else{
                                          echo "$name or $file not found.";
                                  }
                          >
                          }
                          >
                          on the 4th line it fails the if check ($fp = fopen...) and just
                          outputs "$file cannot be opened"
                          >
                          Am I missing something?
                          >
                          A little off-topic, but your code is an example of the Arrow Anti-
                          Pattern:
                          >

                          >
                          http://www.codinghorror.com/blog/archives/000486.html
                          I personally find quite a few things some programmers designate as
                          "anti-patterns" are really just things the particular programmer
                          doesn't like. For example excessive commenting is claimed to be a
                          code smell, but I personally would much rather maintain a piece of
                          code with a lot of comments than a piece of code with none. It's true
                          enough that comments can be used incorrectly, for example using
                          esoteric variable names and using comments to say what they are,
                          variable names should be self-descriptive. And well written code will
                          get its what and how across quite well, but even the best written code
                          can't really convey its why. That's where comments come in.

                          As for the whole "Arrows anti pattern", the author asserts it results
                          in error handler code a long way from where the error might occur.
                          This is also true of exceptions, where the handler doesn't even have
                          to be in the same module. Overuse of exceptions is a far bigger sin
                          in my opinion than nesting ifs. The code and its error handler are
                          part of the same section in the arrow approach, and you can tell what
                          error handle belongs to what code because it will be on the same
                          indentation level.

                          Good code should narrative, which is more true of the arrow pattern
                          than badly used exceptions. There is nothing wrong with the structure
                          of the OP's code. In fact its structure pointed to exactly where the
                          problem lay almost immediately and allowed me to formulate a theory
                          quickly, namely that the script didn't have permission to write to the
                          file being manipulated.

                          As for the OP's problem, it looks from the error message PHP emitted
                          that the PHP user doesn't have write permission for the file in
                          question. I'd suggest adjusting chown, chmod and chgrp on the file,
                          but it looks like you've already done all that. Another possibility
                          is that some other program or script has opened and flocked the file
                          to prevent more than one process writing to it at a time. If the
                          software doesn't release its lock no other application or script can
                          write to it even if they do have permission. If other applications
                          have been accessing the file in question then try checking that they
                          have been closed down properly. If they have and the file is still
                          locked then you may have to resort to a restart of your system.

                          Comment

                          • Jerry Stuckle

                            #14
                            Re: using fopen() in write mode is failing

                            lawrence k wrote:
                            On May 30, 4:08 pm, cscor...@gmail. com wrote:
                            >For some reason, I cannot use fopen() on the file in write mode. The
                            >file "time" is in the same directory as the .php file, with
                            >permissions set to 0766.
                            >>
                            >PHP Version 5.2.5
                            >Apache/2.2.8
                            >>
                            >code snip in question:
                            >>
                            >$file = "time";
                            >function updateParseTime ($name){
                            > global $file;
                            > if (file_exists($n ame) && file_exists($fi le)) {
                            > if(($fp = fopen($file,"wb "))){
                            > $lastmod = filemtime($name );
                            > if(!(fwrite($fp , $lastmod))){
                            > echo "cannot update time";
                            > }
                            > }
                            > else{
                            > echo "$file cannot be opened. \n";
                            > }
                            > }
                            > else{
                            > echo "$name or $file not found.";
                            > }
                            >>
                            >}
                            >>
                            >on the 4th line it fails the if check ($fp = fopen...) and just
                            >outputs "$file cannot be opened"
                            >>
                            >Am I missing something?
                            >
                            >
                            If you chmod $file to 0777 does your script then work?
                            Why would you set the 'x' bit on a non-executable file? That's just
                            asking for even more trouble.

                            --
                            =============== ===
                            Remove the "x" from my email address
                            Jerry Stuckle
                            JDS Computer Training Corp.
                            jstucklex@attgl obal.net
                            =============== ===

                            Comment

                            • Jerry Stuckle

                              #15
                              Re: using fopen() in write mode is failing

                              cscorley@gmail. com wrote:
                              On May 30, 3:08 pm, cscor...@gmail. com wrote:
                              >For some reason, I cannot use fopen() on the file in write mode. The
                              >file "time" is in the same directory as the .php file, with
                              >permissions set to 0766.
                              >>
                              >PHP Version 5.2.5
                              >Apache/2.2.8
                              >>
                              >code snip in question:
                              >>
                              >$file = "time";
                              >function updateParseTime ($name){
                              > global $file;
                              > if (file_exists($n ame) && file_exists($fi le)) {
                              > if(($fp = fopen($file,"wb "))){
                              > $lastmod = filemtime($name );
                              > if(!(fwrite($fp , $lastmod))){
                              > echo "cannot update time";
                              > }
                              > }
                              > else{
                              > echo "$file cannot be opened. \n";
                              > }
                              > }
                              > else{
                              > echo "$name or $file not found.";
                              > }
                              >>
                              >}
                              >>
                              >on the 4th line it fails the if check ($fp = fopen...) and just
                              >outputs "$file cannot be opened"
                              >>
                              >Am I missing something?
                              >
                              Actually, I think it must have something to do with the way this
                              particular webserver is setup (be it apache/php), because it works
                              fine when tested on another server (not maintained by me).
                              What OS is it running on (i.e. if Linux, which distro)? It could be the
                              OS security isn't allowing it, despite the file flags.

                              --
                              =============== ===
                              Remove the "x" from my email address
                              Jerry Stuckle
                              JDS Computer Training Corp.
                              jstucklex@attgl obal.net
                              =============== ===

                              Comment

                              Working...