Page 1 of 1

writing a file

Posted: Sat Nov 25, 2006 10:14 am
by visonardo
Hi, i want know how can i know how many lines has a txt files that im reading. I need know that before work over it.
My problem is that my server doesnt allow me to enable a determinate ip mine to conect from my pc (using mysql administrator) to the server to do the backup here in my pc. I know how to write a txt file, but the bd is like 230mb. I was thinking in a system that write up to (for example) make a file of 1mb and then it done continue the backup in other file. Do im clear? that i need is how to control rigurously how many data i wroted and i would write in the next line and thus each time.

Posted: Sat Nov 25, 2006 3:36 pm
by Chris Corbyn
I'm having difficulty understanding your english ;) but if I've understood you correctly you simply need to open the file in "append" mode:

Code: Select all

$handle = fopen($file, "a+");
This way you can write a line, then discard that line and each time you write to the file it just adds to the end of it. You'll save memory compared with writing in "write" mode (the w flag).

I hope that's what you were asking? :)