proggR Posted July 7, 2008 Share Posted July 7, 2008 So I'm reading in the first line of a file to compare it with the data I want to add to it and if they match it should return a message saying that the data is already there. But It doesn't seem to happen. It just jumps to my else option and prints the data into the file anyway. So I had it printing my fgets value and aparently its not seeing the /n and its grabbing two pieces of data from the file (which take up the first line when you look in notepad) and so of course that value and my one new piece of data don't match. Is there any reason for this? I'm on a Windoze machine so would I have to use fopen($file, 'a+t');? I could just go through and add ."/r/n" "\r\n" instead of ."/n" "\n" to the fwrite since I'm still just testing everything and haven't actually used it on a larger scale yet but I'm writing this on a Windows laptop and will later be uploading it to a Linux server and would rather not write it this way. But is it safe to say that's what's happening here? Pee Ess. I've been reading around and I think the general concensus is no, but is there any way to append to the beginning of the file? Like r+ except it doesn't overwrite the data? I'll probably have to read the old data and then rewrite it but I'd rather not if I could avoid it. Thanks. *edit* made the noob mistake of using the wrong slashes in my OP. Sorry Link to comment https://forums.phpfreaks.com/topic/113549-issues-with-fgets/ Share on other sites More sharing options...
trq Posted July 7, 2008 Share Posted July 7, 2008 If your really are using /r/n and /n then they mean nothing. They ought be \r\n and \n I'll probably have to read the old data and then rewrite it but I'd rather not if I could avoid it. It cannot be avoided. Link to comment https://forums.phpfreaks.com/topic/113549-issues-with-fgets/#findComment-583411 Share on other sites More sharing options...
proggR Posted July 7, 2008 Author Share Posted July 7, 2008 Oops. Typo. I guess I should probably check and make sure I didn't do the same thing at home But aside from that is that whats happening do you think? Link to comment https://forums.phpfreaks.com/topic/113549-issues-with-fgets/#findComment-583414 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.