vidyashankara Posted June 16, 2006 Share Posted June 16, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/12174-php-script-shows-blank-screen-when-reading-big-txt-files/ Share on other sites More sharing options...
jvrothjr Posted June 16, 2006 Share Posted June 16, 2006 Sounds like a time-out issue.php.ini file;;;;;;;;;;;;;;;;;;;; Resource Limits ;;;;;;;;;;;;;;;;;;;;max_execution_time = 30 ; Maximum execution time of each script, in secondsmax_input_time = 60 ; Maximum amount of time each script may spend parsing request datamemory_limit = 8M ; Maximum amount of memory a script may consume (8MB); Maximum time (in secondes) for connect timeout. -1 means no limitmysql.connect_timeout = 60also could be your resources set on your my.ini file Quote Link to comment https://forums.phpfreaks.com/topic/12174-php-script-shows-blank-screen-when-reading-big-txt-files/#findComment-46366 Share on other sites More sharing options...
vidyashankara Posted June 16, 2006 Author Share Posted June 16, 2006 [!--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 secondsmax_input_time = 60 ; Maximum amount of time each script may spend parsing request datamemory_limit = 8M ; Maximum amount of memory a script may consume (8MB); Maximum time (in secondes) for connect timeout. -1 means no limitmysql.connect_timeout = 60also could be your resources set on your my.ini file[/quote]yeah i just tried changing it to 99, still shows a blank screen... Quote Link to comment https://forums.phpfreaks.com/topic/12174-php-script-shows-blank-screen-when-reading-big-txt-files/#findComment-46368 Share on other sites More sharing options...
nogray Posted June 16, 2006 Share Posted June 16, 2006 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 Link to comment https://forums.phpfreaks.com/topic/12174-php-script-shows-blank-screen-when-reading-big-txt-files/#findComment-46373 Share on other sites More sharing options...
vidyashankara Posted June 16, 2006 Author Share Posted June 16, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/12174-php-script-shows-blank-screen-when-reading-big-txt-files/#findComment-46377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.