Php: write to text file

Does anyone know how to make php write to a text file? I’m assuming h88 knows because he’s a smart guy when it comes to this. I would do a quick search online but I’m on my way out the door to class and I just wanted to post this up to give you all time to respond before I get outta class :slight_smile:

I know how to send and recieve variables in flash using PHP, but I want to send those variables to a text file and save them there…

cheers,
Jubs:cowboy:

I’ve done this already once in the forums, check the attachment: :slight_smile:

I know you did it before, but I searched and I couldn’t find it. Trust me, I always search for about 45 minutes before I bother to ask a question, because I know anything that I have trouble with has already been done once or twice before. Thanks man, I’ll check it out :slight_smile:

its not working, and I’m not sure why. I get this error message from the PHP when I hit the submit button:

Warning: fopen(“member.txt”, “a”) - Permission denied in /home/livetosk/public_html/shoutbox/member.php on line 2

Warning: fputs(): supplied argument is not a valid File-Handle resource in /home/livetosk/public_html/shoutbox/member.php on line 3

Warning: fclose(): supplied argument is not a valid File-Handle resource in /home/livetosk/public_html/shoutbox/member.php on line 4

Ok, well I changed the fopen(“member.txt”, “a”) to include the whole path to the file:

fopen(“http://www.livetoskateboard.com/shoutbox/member.txt”, “a”)

so now I don’t get those error messages, but now nothing writes to the text file…There isn’t anything in the text file after I hit submit and then go to text…

did you correctly chmod your files?

what should they be set to? I’m just using the defaults…

Well if you are writing to a file it should be something like 777

the text file should be 777? or the php file?

The file you are writing to. Which sounds like the .txt file in this case.

yeah, that was kind of a stupid question. :slight_smile:

Well when it comes to chmodding there is no stupid questions :slight_smile:

My friend accidently chmodded a directory so you couldn’t read, write or execute it… so he couldn’t access the directory or the files in it… he had to call the hosts and have them delete it then start all over…LOL.

still not working…hmmm…

I guess youshould wait for h88 on that one, that sounds like a PHP issue with the invalid arguments with your fputs() and fclose() things, and I don’t know PHP too well.

yeah me either. thats the problem. Yeah I’m just kinda chillin til he gets back…

ahahahah I got it to work! But I had to use a different script. Now its back to your script! Thanks for the push h88, and if I need any more help I’ll be sure to contact you! :):evil: :ninja: :elderly: :cowboy: :beard: :hat:

Hmm, working fine here, i think there is an issue with ur host, may be they dun allow global variables.

Place this at the top of your script:

extract($_POST);

Then you’ll be able to access those variables.

Working fine. :slight_smile:

Hi h88, do you mind saving the exmple you did as Flash 5, I think this script is exactly what i need!

Quick question! below in my .txt file I want to load my variable from and then save them or update them to the same .txt file. It is only the count0=1 variable I want to save as want it to work like a click counter! With you example can I just change that part of the .txt file?

&link0=google&url0=http://www.google.com&count0=1
&link1=yahoo&url1=http://www.yahoo.com&count1=1
&link2=realitydesigns&url2=http://www.realitydesigns.co.uk&count2=1
&link3=actionscript.org&url3=http://www.actionscript.org&count3=1
&finished=okay&

Thanks

Kev