Hi all, I am trying to insert 1000 above data into a table but after inserting 500 something data its showing an "Internal Server Error". I tried after changing max_execution_time in php.ini and some other methods but no use. But this works fine in localhost. Given below is my code.
$submitted = !empty($_POST);
if($submitted==true)
{
$date = date("Y-m-d",strtotime($_POST["add_date"]));
//select cash data for selected date
$cond_data = "WHERE date_added ='$date'";
$sql_data=$objA->select_rows(TABLEPREFIX.'cash_data','SERIES,SYMBOL',$cond_data);
if(mysql_num_rows($sql_data)>0){
while($row_data=mysql_fetch_array($sql_data)){
$series = $row_data["SERIES"];
$symbol = $row_data["SYMBOL"];
//to find exist data
$cond_exist = "WHERE SERIES='$series' AND SYMBOL='$symbol' AND date_added ='$date'";
$sql_exist=$objA->select_rows(TABLEPREFIX.'cash_stock_scanning','count(*) as nm',$cond_exist);
$row_exist = mysql_fetch_array($sql_exist);
$sql_avg=mysql_query("SELECT AVG(CASE WHEN RowNumber <= 200 THEN Close_price END) AS avg200,
AVG(CASE WHEN RowNumber <= 100 THEN Close_price END) AS avg100,
AVG(CASE WHEN RowNumber <= 50 THEN Close_price END) AS avg50,
AVG(CASE WHEN RowNumber <= 25 THEN Close_price END) AS avg25
FROM ( SELECT @i:= @i + 1 AS RowNumber, Close_price
FROM cash_data,
(SELECT @i:=0) AS i
WHERE SERIES='$series' AND SYMBOL='$symbol' AND date_added <= '$date' ORDER BY date_added DESC
) AS Data");
$row_avg=mysql_fetch_array($sql_avg);
//to last 25 days closeprice sum and average get data of SYMBOL
$avg25 = $row_avg["avg25"];
//to last 50 days closeprice sum and average get data of SYMBOL
$avg50 = $row_avg["avg50"];
//to last 100 days closeprice sum and average get data of SYMBOL
$avg100 = $row_avg["avg100"];
//to last 200 days closeprice sum and average get data of SYMBOL
$avg200 = $row_avg["avg200"];
//saving data
if($row_exist["nm"]>0){ //if exist update data
$fields= "200_MDA='$avg200',100_MDA='$avg100',50_MDA='$avg50',25_MDA='$avg25'";
$pass_add=$objA->update_rows(TABLEPREFIX.'cash_stock_scanning',$fields,$cond_exist);
}else{ //insert data
$fields="SERIES,SYMBOL,200_MDA,100_MDA,50_MDA,25_MDA,date_added";
//echo $fields="SERIES,SYMBOL,200_MDA,100_MDA,50_MDA,25_MDA,15_MDA,5_MDA,7_MDA,21_MDA,MACD_9, MACD_0,RSI_30,RSI_70,STOCHASTIC_20,STOCHASTIC_80,date_added";
$values = "'$series','$symbol','$avg200','$avg100','$avg50','$avg25','$date'";
$pass_add=$objA->insert_fields(TABLEPREFIX.'cash_stock_scanning',$fields,$values);
}
}//end while
if($pass_add)
{
$msg='Content has been added sucessfully!';
$_SESSION['sess_Msg']=$msg;
header('location:index.php');
exit();
}
else
{
$msg="Error in updating content!";
$_SESSION['sess_Msg']=$msg;
}
}else{
$msg = "No Cash Data in the table.";
$_SESSION['sess_Msg']=$msg;
}
}