Warning: fread() [function.fread]: Length parameter must be greater than 0 ...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • macdalor
    New Member
    • Jan 2010
    • 27

    Warning: fread() [function.fread]: Length parameter must be greater than 0 ...

    could someone please explain to me why I get the above error msg? I took this script from the net, it apparently works correctly for others but not for me and I'd like to understand why.

    thx

    Code:
    <?php
    $file = "guestbook.txt";
     
    if (fopen($file, "r")) {
    $fil = "guestbook.txt";
    $fo = fopen ($fil, "r");
    $con = fread ($fo,filesize ($fil));
    fclose ($fo);
    echo "$con";
    } else {
    echo "<h3>Sorry there was an error please contact us now<h3>";
    }
    ?>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I guess that filesize() returns false, which is converted to 0.

    Comment

    • macdalor
      New Member
      • Jan 2010
      • 27

      #3
      hi Dormilich and thx for your answer. What do I need to do to make it work then?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        you could try file_get_conten ts().

        Comment

        • macdalor
          New Member
          • Jan 2010
          • 27

          #5
          I get this error with file get content():

          Parse error: syntax error, unexpected T_STRING in ...

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            the full error message would be really helpful …

            … although my guess is, you didn’t read the manual entry.
            Last edited by Dormilich; Jan 10 '10, 01:34 AM. Reason: removed testing

            Comment

            • macdalor
              New Member
              • Jan 2010
              • 27

              #7
              the rest of the message of was giving the line No which is the line of this additon (get content)

              Sorry but I'm really not used to this kind of posts, I am no programer what so ever. Can you explain please (manual entry? testing 123?)

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #8
                Please consult the manual on how to use core functions. See: file_get_conten ts(). If this does not suit you, see the See also towards the end of that page.

                Comment

                Working...