Problems Adding to a file...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply

Am I Missing Something Stupid?!

yes
2
100%
no
0
No votes
 
Total votes: 2

mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

Problems Adding to a file...

Post by mindmeddler2002 »

Ok,
first of all, its been a while...
secound... This never happened before to me....


*In Theory*
I got a file, that is made up of TONS of lines.
All I want to do is add a line to the bottom....

Simple right..

wrong.

I tried a few ways.
I tried just fput it into the file after it was opened...

All it did was replace the whole file with 1 line....
I tried sevaral ways of doing this.
Includeing copying the files contents into a varabile, and then fputing it back.... Figuring since it replaced it.

Nope.

This first way I tried was saving the info, then unlinking it, then remaking it, and saving.

Copy, Deleate, Remake, Past.
Basicly...
When I did this before I had to use that for some reason...

Anyways I get a unlink failure.
When I make it so that there is no unlink failure
(had to move folders and files around, some hidden permisions or something on XP)

IT REPLACES THE FILE AGAIN WITH ONE LINE!!!

I spent 7 hours working on syntax and stuff...
I even tried to download the file to a array, then put it back in...
Just wont work (my code on the last one was a little off I think)

Anyways,
SUGGESTIONS NEEDED PLEASE....

Thanks!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://www.php.net/manual/en/function.f ... quote]mode specifies the type of access you require to the stream. It may be any of the following:
...
'a' - Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
'a+' - Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it. [/quote]
mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

Did that...

Post by mindmeddler2002 »

I did use a and a+
it would either replace the file itself, or give me a array to string conversion error....

got anything better?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

or give me a array to string conversion error....
uh?

Code: Select all

$fd = fopen($filename, 'a') or die("it's all over");
fputs($fd, "appending new string\n");
fclose($fd);
doesn't work?
mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

figured it out

Post by mindmeddler2002 »

Ok...

Here was the problem...

Bare with me this is a new one on me...

Apparently when i checked the file, i alwasy tried to edit it.
It was either that and it changed the file permisions....

Or the account, that i was logged in with had its own error that i found later. Apparently when I edited the account, it changed the permissions once again.

Something with XP...
Folders and files i create cant be edited with PHP unless i make it with PHP...

Any suggestions?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

set the permissions of the "root" directory according to your needs and enable inheritage of permissions for subdirs
mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

it is

Post by mindmeddler2002 »

the root is, its when i add a new folder or file that it changes just that file back....
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

with permission inheritage enabled? How do you create that folder?
I'm running w2k and totally agree with microsoft's own statement if you have w2k there's no need to upgrade to XP
Don't let me be misunderstood. I know many ppl. that are pleased with XP and I wouldn't try to convience them of something else but to me it is eXtreme Problem ;)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

ah, and permission granted to webserver/php-account ;)
mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

reason for XP

Post by mindmeddler2002 »

Well see this computer was originally built to be a server...

aluminum case and powe supply.

Then i found where i use to live, with DSL
they blocked port 80 and 8080 and 88

horrible huh

anyways...
i moved and have cable now (works great and is faster cause i am the only person in my loop, get awsome speeds)

anyways, cause i thought it was not going to be a server, i installed some nice things, like TV tunner (ati all in wonder card) and a creative audigy platnum ex drive (got the best sound)

anyways, and some other special stuff....

2k would suck with this.
i had a labtop and 2k would not reconize the NIC card. A NIC CARD!

anyways... that and it really hated the active matrix display... its not TV not suppose to get horizontal lines cause the attena does not work....

ect ect ect
i have tons of problems....

besides xp comes with a newer IIS

come over to the dark side
volka i am ur father

wait j/k
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Never! :D
I suffered too long SuSE-linux's firewall to appreciate ANY preinstalled firewall and I'm under the impression "the more colors the more trouble" ;)
I hate the idea of installing software to prevent my OS from phoning home.

no, serious, I have no need for XP, even my notebook works perfect with w2k. No new OS until INCREDIBLE features I CAN'T live without are available, no new hardware until the current is burned out ;)
mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

lol ok let me finish this

Post by mindmeddler2002 »

The BEST OS IN HISTORY!

Linux in the Raw!

2nd is Mac OS
belive it or not mac os is kind of like communism.
it has good ideas and intent, just does not work...

then the 3rd is windows 95, the only original copy of windows with a good GUI and no problems....
it was the only stable os windows made. BTW< XP DOES HAVE A BLUE SCREEN OF DEATH.

i saw mac over windows, cause i seen a few versions that actually were inovative... way more than windows....

personally...

my fav OS is IOS v 11.2 in a cisco router...

why?

cause it is simple. and does what it needs to.
mwahaha
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

What about Lindows?

;D
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

microsoft's closed-source/license strategy paired with unix's gui comfort/time-to-load. I think I can spare it ;)
(and don't take this post too serious)
mindmeddler2002
Forum Newbie
Posts: 21
Joined: Mon Nov 04, 2002 3:09 pm
Location: US, PA, Harrisuburg

lindows

Post by mindmeddler2002 »

now all we need is a mac os and novel combo...

macovel OS


...

lindows is a little bit weird. I hear bad things...

its just linux using whine...
but i hear it does not set up right or something
Post Reply