Jump to content

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?
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
[!--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...
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.
[!--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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.