Hi Guys
I am generating a text file using the php from MySL database.
Generaly the php code gets the data from mysql and write in a text file. the problem I am having is that like 20, 25000 records the script stop executing and gives an error sometime blank page and the text file never generated
Smaller records are all ok
Mysql has arround 200,000 records all are numbers like
ID1,111,222,333,444,555,666,777
ID2,111,222,333,444,555,666,777
......
The file generated usually when the button clicked.
this is a code I am using
// this query will get all the data
// a db link for queries
$lh = mysql_connect( 'localhost', 'user', 'pass' );
// and a controller link
$clh = mysql_connect( 'localhost', 'user', 'pass', true );
if ( mysql_select_db ( 'mydb', $lh ) )
{
$began = time();
$tout = 60 * 5; // five minute limit
$qry = "SELECT tid, ticker, name, per, ndate, open, high, low, close, vol from `meta_data1` WHERE dispdate BETWEEN '$datefrom' AND '$dateto' order by tid DESC";
$rh = mysql_unbuffered_query( $qry, $lh );
$thread = mysql_thread_id ( $lh );
while(list($totid, $toticker, $toname, $toper, $tondate, $toopen, $tohigh, $tolow, $toclose, $tovol) = mysql_fetch_row( $rh ) )
{
$snews11_c[]="$toticker,$toname,$toper,$tondate,$toopen,$tohigh,$tolow,$toclose,$tovol\r\n";
// echo"$totid, $toticker, $toname, $toper, $tondate, $toopen, $tohigh, $tolow, $toclose, $tovol<br>";
if ( ( time() - $began ) > $tout )
{
// this is taking too long
mysql_query( "KILL $thread", $clh );
break;
}
}
}
// get the result with for loop
if($snews11_c!=""){
foreach ( $snews11_c as $v11_c ) {
if ( trim($v11_c)!="" or trim($v11_c)!="0" )
{
$mnews11_c = "$v11_c".$mnews11_c;
}
}
}
$outputtext_c = "myheading here\r\n$mnews11_c"; // day
//create file if not exist
$write_file_c = "./data_file.txt";
$fp_c = @fopen($write_file_c, 'w+') or die("Couldn't open ".$write_file_c);
if (!$fp_c){ echo 'error in file : data_file.txt<br>'; exit; }
@fwrite($fp_c, $outputtext_c);
@fclose($fp_c);
//echo"created";
// closing connection
mysql_close($lh);
mysql_close($clh);
Any help is realy realy appreciated I am realy in a need of solution please help.