infinite loads while writing a file with more than 10000 lines

Reply

Join Date: Jan 2009
Posts: 1,396
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 170
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: infinite loads while writing a file with more than 10000 lines

 
0
  #11
Aug 24th, 2009
Originally Posted by chavansoft View Post
cwarn23,

I tried it but still could not solve the problem. please I'm trying with all soughts of different function but could not fix it. Please help me.

Thank you for the Reply

Regards
chavan
perhaps post a little more of the code, the balls up could be the combination of another bottleneck with this one
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it

Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 15
Reputation: chavansoft is an unknown quantity at this point 
Solved Threads: 0
chavansoft chavansoft is offline Offline
Newbie Poster

Re: infinite loads while writing a file with more than 10000 lines

 
0
  #12
Aug 26th, 2009
Hi,
Any body please help me in fixing this issue. i'm really tried in trying in this issue for more than 5 days.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 15
Reputation: chavansoft is an unknown quantity at this point 
Solved Threads: 0
chavansoft chavansoft is offline Offline
Newbie Poster

Re: infinite loads while writing a file with more than 10000 lines

 
0
  #13
Aug 26th, 2009
Originally Posted by almostbob View Post
perhaps post a little more of the code, the balls up could be the combination of another bottleneck with this one
almostbob,

This is the complete code in the post of my form, please help me in solving this issue. the program is not getting redirected with large number of lines

here is the code you asked for
$list = file_get_contents($imgpath);
$listarray = array();
$listarray = explode("\n",$list);
$count_line = count($listarray);


$key = array();
$newline ='';
$store ='';
for($i =0; $i <= count($listarray) ; $i++)
{
if($i == count($listarray))
{

/*$fp = fopen($imgpath, 'w');
fwrite($fp, $store);
fclose($fp);*/
file_put_contents($imgpath,$store);
header("location: index.php");


}
$name = $listarray[$i];

// Replaces the Empty Line
$line = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", '', $name);
$line = trim($line);
if($line !='')
{
// Apply URL

$line = link($line);

$fault =0;
$key[] = $line;
$store .= trim($line)."\r\n";
}
}

Regards
Last edited by chavansoft; Aug 26th, 2009 at 7:43 pm.
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,540
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 137
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Posting Virtuoso

Re: infinite loads while writing a file with more than 10000 lines

 
1
  #14
Aug 27th, 2009
I have checked your code and although it's a bit messy and buggy, a corrected version (still messy) is as follows:
  1. $list = file_get_contents($imgpath);
  2. $listarray = array();
  3. $listarray = explode("\n",$list);
  4. $count_line = count($listarray);
  5.  
  6.  
  7. $key = array();
  8. $newline ='';
  9. $store ='';
  10. for($i =0; $i <= count($listarray) ; $i++)
  11. {
  12. $name = $listarray[$i];
  13.  
  14. // Replaces the Empty Line
  15. $line = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", '', $name);
  16. $line = trim($line);
  17. if($line !='')
  18. {
  19. // Apply URL
  20.  
  21. $line = link($line);
  22.  
  23. $fault =0;
  24. $key[] = $line;
  25. $store .= trim($line)."\r\n";
  26. }
  27. }
  28. if (strlen($store)==0) {
  29. die('<h1>Store is empty!</h1>');
  30. }
  31. /*$fp = fopen($imgpath, 'w');
  32. fwrite($fp, $store);
  33. fclose($fp);*/
  34. file_put_contents($imgpath,$store);
  35. header("location: index.php");
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - Oopy Doopy Do 2U2!
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 15
Reputation: chavansoft is an unknown quantity at this point 
Solved Threads: 0
chavansoft chavansoft is offline Offline
Newbie Poster

Re: infinite loads while writing a file with more than 10000 lines

 
0
  #15
Aug 27th, 2009
cwarn23,

I tried this before, it did not work, for that reason i have changed it into the new one , which i have posted already.

Thanks for the reply, Help me fix this, please
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,540
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 137
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Posting Virtuoso

Re: infinite loads while writing a file with more than 10000 lines

 
0
  #16
Aug 28th, 2009
Did you try my version anyway because I added 3 lines you wouldn't have had before and see if the page ends early with an error message telling you the problem.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - Oopy Doopy Do 2U2!
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 15
Reputation: chavansoft is an unknown quantity at this point 
Solved Threads: 0
chavansoft chavansoft is offline Offline
Newbie Poster

Re: infinite loads while writing a file with more than 10000 lines

 
0
  #17
Aug 31st, 2009
Hi

Thank you, I forgot that three lines. But it doesn't work. what am I suppose to do

Regards
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,540
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 137
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Posting Virtuoso

Re: infinite loads while writing a file with more than 10000 lines

 
0
  #18
Sep 1st, 2009
If the error saying "store is empty" did not trigger then I would suggest checking what those two variable contain. So run the following code to make sure that the variables are set correctly.
  1. $list = file_get_contents($imgpath);
  2. $listarray = array();
  3. $listarray = explode("\n",$list);
  4. $count_line = count($listarray);
  5.  
  6.  
  7. $key = array();
  8. $newline ='';
  9. $store ='';
  10. for($i =0; $i <= count($listarray) ; $i++)
  11. {
  12. $name = $listarray[$i];
  13.  
  14. // Replaces the Empty Line
  15. $line = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", '', $name);
  16. $line = trim($line);
  17. if($line !='')
  18. {
  19. // Apply URL
  20.  
  21. $line = link($line);
  22.  
  23. $fault =0;
  24. $key[] = $line;
  25. $store .= trim($line)."\r\n";
  26. }
  27. }
  28. die('<h1>$imgpath</h1>'.$imgpath.'<br><h1>$store</h1>'.$store);
  29. /*$fp = fopen($imgpath, 'w');
  30. fwrite($fp, $store);
  31. fclose($fp);*/
  32. file_put_contents($imgpath,$store);
  33. header("location: index.php");
Also make sure $imgpath is a relative path and that the directories in it's path already exist.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*`
My favourite PC. - Oopy Doopy Do 2U2!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 739 | Replies: 17
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC