It is possible that your script times out before reaching the end. You can try to use:
set_time_limit(0);
at the start of your script, to allow it to run (indefintely) until completed.
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Did you try to change max_input_time and memory_limit ?
pritaeas
Posting Expert
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
Just wondering, why are you writing 10000 lines into a file?
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
$fp = fopen($imgpath, 'w');
fwrite($fp, $store);
fclose($fp);
Try replacing that code with the following:
file_put_contents($imgpath,$store);
A much more efficient function.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
Try this but you will need to wait for the page to be fully loaded before you expect to see results. So try the following:
<?
set_time_limit(0);
ini_set('memory_limit','200M');
//above are the very first lines of the document
//some code in here for $imgpath and $store
if (empty($imgpath)) {
die('invalid image path');
}
file_put_contents($imgpath,$store);
echo 'image stored at: '.$imgpath;
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
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
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
I have checked your code and although it's a bit messy and buggy, a corrected version (still messy) is as follows:
$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");
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
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.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259
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.
$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.'<h1>$store</h1>'.$store);
/*$fp = fopen($imgpath, 'w');
fwrite($fp, $store);
fclose($fp);*/
file_put_contents($imgpath,$store);
header("location: index.php");
Also make sure $imgpath is a relative path and that the directories in it's path already exist.
cwarn23
Occupation: Genius
3,033 posts since Sep 2007
Reputation Points: 413
Solved Threads: 259