hello, i am hosting a game and i am storing the character files online and they save to .txt file on my site(e.g. god ownz.txt, jim.txt, ect...). I was just wondering if it was possible to edit a .TXT file through php

so heres an example:

theres a box that you type the name into (E.G GOD OWNZ.txt)
and a button that says (click to get ADMIN)
so when you press it it edits the line that says:
Character-rights = 0
to
Character-rights = 3

if any one has a code for this PLEASE post it

THANKS.

    Rrrriiiggghhhhtttt, 😉 ill have a go with this after when i come back home but can you tell me, does this do what il looking for? coz i had a quick look at it and its a little confusing ill have a proper look after Thanks for replying 😉

    EDIT: Oh and if this has anything to do with Mysql sorry but i realy cant be assed recoding my full game to save to a database 🙁 but if its not then ill give it a go.

      If you can't be bothered to use MySQL and you can't be bothered to read the instructions on how to read and write to a file why do you think anyone here should be bothered to do the work for you?

      If you actually want to put some effort in there is a very basic introduction to php file handing here. That might make the php.net page a bit easier to understand or it might be enough for you to do what you want.

        DaiLaughing;10922077 wrote:

        If you can't be bothered to use MySQL and you can't be bothered to read the instructions on how to read and write to a file why do you think anyone here should be bothered to do the work for you?

        If you actually want to put some effort in there is a very basic introduction to php file handing here. That might make the php.net page a bit easier to understand or it might be enough for you to do what you want.

        its not that i cant be bothered its that the game is REALY hard to trancfer to mysql coz u cant edit the files if they r in mysql i have done it before

          Once you have set up the connection I find it is easier to change the mysql data. File handling is harder (for me).

            God Ownz;10922129 wrote:

            its not that i cant be bothered its that the game is REALY hard to trancfer to mysql coz u cant edit the files if they r in mysql i have done it before

            use phpmyadmin to edit the data once its in SQL... also, please use full words

            coz ppl who tlk like dis r obv lzy
            

            As I mentioned before, you should ideally use xml if you are going to stick with flat files... you can then use DOM to set and retrieve values much easier

              <? 
              //file you want to write to it creates if file dosent exist
              
              $myfile ="test.txt";
              
              //open the file
              
              $fh = fopen($myfile, 'w') or die("file wont open");
              
              //txt you want to insert
              
              $stringData = "text you want to place in file";
              
              //writeing
              
              fwrite($fh, $stringData);
              
              //closeing file and saves
              fclose($fh)
              ?> 
                Write a Reply...