Re: Opening large file problem - fopen
| From: | Kim Steinhaug | Date: | Tue, 16 Dec 2003 11:02:35 +0000 |
| Subject: | Re: Opening large file problem - fopen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-172788@lists.php.net to get a copy of this message | ||
I found that the script accually breaks on this line :
[Mon Jul 14 12:17:26 2003] [error] PHP Notice: INSERT INTO tbl_news
(band_id, date, heading,heading_eng, ingress,ingress_eng, body,body_eng)
VALUES (-1,"2003-07-14","TESTAMENT endelig til Norge!!!", "Spiller p Rock
in - spesial treat for the fans!", "", "", "Testament + support
spiller pe
Rock In onsdag 30.juli. Grunnet opptatte strre spillesteder ensket Testament
likevel gj/re Norge, med en kveld dedikert til fansen som har mttet vente
pt Norgesbesket i su mange r..
Rock In blir garantert utsolgt, sr her er det bare hamstre billett ss fort
s mulig!!
Billetter pl billettservice/posten
Bill.pris 250,-+avg. - Drene cpner 19.00","") in
/home/xxx/public_html/admin/news_send.php on line 27
[Mon Jul 14 12:17:26 2003] [error] PHP Warning: Cannot modify header
information - headers already sent by (output started at
/home/xxx/public_html/admin/news_send.php:2) in
/home/pilotman/public_html/admin/news_send.php on line 34
---
Hope this helpls.
--
Kim Steinhaug
---------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---------------------------------------------------------------
"Kim Steinhaug" <kim@steinhaug.com> wrote in message
news:20031215234127.92362.qmail@pb1.pair.com...
> Hello
>
> Im having real problems working with large files in PHP. At
> the moment Im trying to parse an error_log file, and it works
> like a charm, except that the scipt stopps after parsing around
> 70.000 lines, or around 8MB of data. Im using this :
>
> $file = "error_log"; // 280MB file
> if($fp=fopen($file, "r+"))
> {
> while($line=trim(fgets($fp)))
> {
> // Do the business
> }
>
> }
>
> Surely this is not the way to work with e.g. a 280MB file. I solved the
> sollution by chopping the file into 7MB files, and adding a fileopen
> loop around the script above which solves my problem. But ->
> How do I parse the 280MB file all in 1 go?
>
> I have plenty of timeout and plenty of RAM in the php.ini file, so the
> problem isnt here.
>
> --
> Kim Steinhaug
> ---------------------------------------------------------------
> There are 10 types of people when it comes to binary numbers:
> those who understand them, and those who don't.
> ---------------------------------------------------------------