Click here to Skip to main content
Sign Up to vote bad
good
See more: HTMLPHP
When I make a questionssheet and I want php to save it in a .txt data, there always just the answers of the last person.
Code:
if ($_GET['reason'] <>"")
{
$handle=fopen ("answer.txt", "w");
fwrite ($handle, $_GET['reason']);
fwrite ($handle, "|");
}
	else
{
	echo "Please give the reason!". "<br />";
} 
?>
 
Did I forget something?
I think the problem is, that it always overwrite the last one.
Posted 24 Dec '11 - 13:31
Edited 25 Dec '11 - 8:08

Comments
Dalek Dave - 24 Dec '11 - 19:49
Edited for code block
SAKryukov - 24 Dec '11 - 19:49
You forgot to think; and this is not curable. --SA
Chi Ller - 24 Dec '11 - 19:54
ahahah very very funny it´s just a part of the code theres already the part where´s the 'reason' if i knew the answer, i wouldn´t ask... 1.think->you forgot 2.write->you´ve done first
SAKryukov - 25 Dec '11 - 14:48
Sure, I know it's not very useful, but I though you could take the hint. To suggests what can you do on server side, one would need to know what you try to do on client side. In other words, there is not a question here -- you don't share important information. So the short answer will be: 1) on client side, post (not "get", by the way) all you need (not just the latest, etc.) 2) on server side, process it properly. In other words, just plan what do you need and implement it. You question does not help here. --SA
Chi Ller - 25 Dec '11 - 15:20
i´ve tried it with post but then it won´t create a .txt file

2 solutions

I don't know php but looks like you are opening a file to write to and not append. You could also try giving each file a unique name so that you are creating a file for each user/answer set.
  Permalink  
I want more then my last salary Poke tongue | ;-P
Regards.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 355
1 Sergey Alexandrovich Kryukov 338
2 Arun Vasu 315
3 Maciej Los 208
4 Aarti Meswania 180
0 Sergey Alexandrovich Kryukov 9,755
1 OriginalGriff 7,549
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 11 Mar 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid