| | |
infinite loads while writing a file with more than 10000 lines
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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
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
•
•
Join Date: Aug 2009
Posts: 15
Reputation:
Solved Threads: 0
•
•
•
•
perhaps post a little more of the code, the balls up could be the combination of another bottleneck with this one
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.
I have checked your code and although it's a bit messy and buggy, a corrected version (still messy) is as follows:
php Syntax (Toggle Plain Text)
$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++) { $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"; } } if (strlen($store)==0) { die('<h1>Store is empty!</h1>'); } /*$fp = fopen($imgpath, 'w'); fwrite($fp, $store); fclose($fp);*/ file_put_contents($imgpath,$store); header("location: index.php");
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
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/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
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.
Also make sure $imgpath is a relative path and that the directories in it's path already exist.
php Syntax (Toggle Plain Text)
$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++) { $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"; } } die('<h1>$imgpath</h1>'.$imgpath.'<br><h1>$store</h1>'.$store); /*$fp = fopen($imgpath, 'w'); fwrite($fp, $store); fclose($fp);*/ file_put_contents($imgpath,$store); header("location: index.php");
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
![]() |
Similar Threads
- Password Guessing + Accessing command + writing to a file (C++)
- Parsing text from a SMI file and writing to a file (Python)
- Writing to file (Java)
- Writing to File in Client/Server app (Java)
- writing to file (Python)
- Parsing Log file and writing it into array/file (C)
- writing to a file (C++)
- Help with reading and writing from file (C++)
- Writing in a file (C++)
Other Threads in the PHP Forum
- Previous Thread: How to use this function FillList ($sql, $selected=0)
- Next Thread: string comparsion
Views: 739 | Replies: 17
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email encode error file files folder form forms function functions google howtowriteathesis href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple multipletables mysql oop parse paypal pdf php problem provider query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table template tutorial update updates upload url validation validator variable video web xml youtube






