PDA

View Full Version : php: write to text file



Jubba
December 4th, 2002, 08:58 AM
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 :)

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:

h88
December 4th, 2002, 11:54 AM
I've done this already once in the forums, check the attachment: :)

Jubba
December 4th, 2002, 01:17 PM
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 :)

Jubba
December 4th, 2002, 02:24 PM
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

Jubba
December 4th, 2002, 02:35 PM
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...

lostinbeta
December 4th, 2002, 02:48 PM
did you correctly chmod your files?

Jubba
December 4th, 2002, 03:12 PM
what should they be set to? I'm just using the defaults...

lostinbeta
December 4th, 2002, 03:14 PM
Well if you are writing to a file it should be something like 777

Jubba
December 4th, 2002, 03:21 PM
the text file should be 777? or the php file?

lostinbeta
December 4th, 2002, 03:23 PM
The file you are writing to. Which sounds like the .txt file in this case.

Jubba
December 4th, 2002, 03:31 PM
yeah, that was kind of a stupid question. :)

lostinbeta
December 4th, 2002, 03:33 PM
Well when it comes to chmodding there is no stupid questions :)

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.

Jubba
December 4th, 2002, 03:36 PM
still not working...hmmm...

lostinbeta
December 4th, 2002, 03:39 PM
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.

Jubba
December 4th, 2002, 03:41 PM
yeah me either. thats the problem. Yeah I'm just kinda chillin til he gets back...

Jubba
December 4th, 2002, 04:46 PM
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:

h88
December 4th, 2002, 07:05 PM
Hmm, working fine here, i think there is an issue with ur host, may be they dun allow global variables.

h88
December 4th, 2002, 07:08 PM
Place this at the top of your script:



extract($_POST);


Then you'll be able to access those variables.

h88
December 4th, 2002, 07:10 PM
Working fine. :)

kev
February 7th, 2003, 10:13 AM
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