Jump to content

Archived

This topic is now archived and is closed to further replies.

vidyashankara

PHP Script shows blank screen when reading big txt files.

Recommended Posts

I have a script which is required to read certain text files and output results. The problem is the script shows up a blank screen when the Text file is very big... i am talking about text files which have about 40000 lines.

right now, this is my code

[code]
$contents = file_get_contents($file);
$title =  preg_replace('/^(?!TITLE).*?(?:\n|$)/m','',$contents);
$title = substr($title ,6, 44);
[/code]

The script fails to output $title for huge files, if the files are small, the script shows up.

what do i do?

Share this post


Link to post
Share on other sites
Sounds like a time-out issue.

php.ini file

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)

; Maximum time (in secondes) for connect timeout. -1 means no limit
mysql.connect_timeout = 60

also could be your resources set on your my.ini file

Share this post


Link to post
Share on other sites
[!--quoteo(post=384667:date=Jun 16 2006, 12:26 PM:name=jvrothjr)--][div class=\'quotetop\']QUOTE(jvrothjr @ Jun 16 2006, 12:26 PM) [snapback]384667[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Sounds like a time-out issue.

php.ini file

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)

; Maximum time (in secondes) for connect timeout. -1 means no limit
mysql.connect_timeout = 60

also could be your resources set on your my.ini file
[/quote]

yeah i just tried changing it to 99, still shows a blank screen...

Share this post


Link to post
Share on other sites
This is just a guess, but maybe the server doesn't have enough room to open the big file at once,

Try to use fopen, fread, fclose to open the file in pieces instead of one big chunk.

This way, the variables don't need a lot of memory to run.

Share this post


Link to post
Share on other sites
[!--quoteo(post=384674:date=Jun 16 2006, 12:33 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ Jun 16 2006, 12:33 PM) [snapback]384674[/snapback][/div][div class=\'quotemain\'][!--quotec--]
This is just a guess, but maybe the server doesn't have enough room to open the big file at once,

Try to use fopen, fread, fclose to open the file in pieces instead of one big chunk.

This way, the variables don't need a lot of memory to run.
[/quote]

there were 8 php.ini files on my system, changed it all. the server has ike 2 gb memory. a 2 mb file should be a problem.
i am running it on my system itself. i am trying to read it in chunks.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.