Added: 2 years ago
From: flash4real
Views: 3,763
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (11)

Sign In or Sign Up now to post a comment!
  • yep, can´t make it work either

  • does not work

  • Hello and thank you so much - I haven't written a program since the 90s and this is awesome, I wanted to ask a few questions.

    First of all - I couldn't get the line "$handle = fopen('text.txt', 'a')" to work without putting the a inside inverted commas. Is that normal?

    Second, when I save the file, it doesn't write over itself but the text is added to the back end of the file; in other words if I save four different sentences, one at a time, the text file retains them all, is that correct? Thx

  • @TsumiESM Yes, the 'a' should be in inverted commas.

    Different letters do different things - 'a' appends to the file. If you want it to overwrite, use 'w' instead.

  • @flash4real Ah, thank you thank you. I gotta say I'm really enjoying this. The last program I wrote was in AppleBasic heh - this is fantastic, to be learning to code again. Thank you.

  • @flash4real Using 'w' doesnt seem to change a thing for me in regards to overwriting the txt file. 'a' and 'w' do the same thing for me or atleast it seems that way. Am I doing something wrong?

  • @gabriellippincott10

    Here are the different modes:

    r - read

    r+ - read, write, prepend

    w - write, truncate

    w+ - read, write, truncate

    a - write, append

    a+ - read, write, append

  • @TsumiESM I had the same issue with the variable a first ,it gave me error code of an undefined variable for a if I didnt put it in inverted commas('a'). Is it supposed to constantly rewrite over the same txt file?

  • It dont works with /a ..... only, with "a"

    $handle = fopen('text.txt' , "a");

    But if I enter the text, it saves it, but if i leave the field emptyt it wrote: Your file has been saved.

    What should be the problem?

  • have you attempted it? send me the code i'll take a look at it.

  • How would I get it to work with a form that takes a name and last name. Seems easier with one text field but with two I can't figure it out. I also would need it to print the first and last name into a text document

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more