Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Php For Dummies - Php Tutorial 7

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,743
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 26, 2009

In this tutorial you will learn how to get a php script to write user-inputed data to a text file.

There will be many more tutorials, so be sure to hit the subscribe button to make sure you receive them all!.

If you would like to get into contact with me, send me a Youtube Message, or add a message in the comments. You can also reach me on my forum http://www.howtocompute.org

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (flash4real)

  • 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 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

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

see all

All Comments (11)

Sign In or Sign Up now to post a comment!
  • @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?

  • yep, can´t make it work either

  • does not work

  • @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.

  • 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?

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