
07-25-04, 02:47 PM
|
|
Wannabe Coder
|
|
Join Date: Jun 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
.txt php scripting help!
I recently downloaded a script, for a guestbook and i changed it but when it adds something to a .txt file it adds it to the bottom of that file, making it show at the bottom when viewing it. Like, the newest is at the bottom, well anyway I want to change it so it inputs the information into the .txt file at the top, how would this work?
The script is below.
|

07-25-04, 03:28 PM
|
|
Wannabe Coder
|
|
Join Date: May 2004
Location: CO
Posts: 214
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Scratch this script and store to mySql. That would be my solution.
|

07-25-04, 03:35 PM
|
|
Wannabe Coder
|
|
Join Date: Jun 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
One problem, I don't know MYSQL that good, and I don't even know if it stores images or something :S
See? I don't know what I'm talking about, so for me it's better in a .txt 
|

07-25-04, 03:39 PM
|
|
Wannabe Coder
|
|
Join Date: Jun 2003
Posts: 242
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Agree with what nekeno said about mysql. But if you're dead set on text files, how about making it easier on yourself by reading from the bottom line up. That way you don't have to write your own function to store at the beginning of the file instead of appending it.
This code might help you out:
Kevin
|

07-25-04, 03:41 PM
|
|
Wannabe Coder
|
|
Join Date: Jun 2003
Posts: 242
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OH, and by the way, the above code was used in another script, but you should be able to easily adapt it to your needs.
OH, and mysql is really worth learning. Once your text file gets big enough, believe me, you'll wish that you had mysql to work with. Just a friendly tip 
Kevin
|

07-25-04, 03:56 PM
|
|
Wannabe Coder
|
|
Join Date: Jun 2004
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by kvnband
OH, and by the way, the above code was used in another script, but you should be able to easily adapt it to your needs.
|
NO! I'm struggling already!
>_<
|

07-25-04, 04:59 PM
|
 |
Code Guru
|
|
Join Date: Jun 2004
Location: Oregon
Posts: 758
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well if you are dead set on writing to the top of the file instead of the bottom, which is what fopen(blah, 'a') does (a for append). Then what you have to do is read in the whole file then write over the entire thing with YournewContents . YouroldContents.
I have no clue if that will work, I just saw it scribbled on some TP in the men's restroom. Hope it helps.
__________________
Hawk Enterprises -- Home to PHP games, open-source code, tutorials and free downloads
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|