使用php reader在数据库中插入超过1500条记录的Excel工作表会产生空白页 在某些情况下,PHPExcel会消耗大量内存。请启用详细日志记录和(如果您可以在主机上执行)增加max\u execution\u time和memory\u limi

使用php reader在数据库中插入超过1500条记录的Excel工作表会产生空白页 在某些情况下,PHPExcel会消耗大量内存。请启用详细日志记录和(如果您可以在主机上执行)增加max\u execution\u time和memory\u limi,php,bulkinsert,import-from-excel,Php,Bulkinsert,Import From Excel,使用php reader在数据库中插入超过1500条记录的Excel工作表会产生空白页 在某些情况下,PHPExcel会消耗大量内存。请启用详细日志记录和(如果您可以在主机上执行)增加max\u execution\u time和memory\u limit。我已经增加了两个参数-execution time n memory limit..但同样的问题请增加error\u reporting并启用display\u errors如下:对于8000条记录,其行为与以前一样…(空白页)对于4000

使用php reader在数据库中插入超过1500条记录的Excel工作表会产生空白页
在某些情况下,
PHPExcel
会消耗大量内存。请启用详细日志记录和(如果您可以在主机上执行)增加
max\u execution\u time
memory\u limit
。我已经增加了两个参数-execution time n memory limit..但同样的问题请增加
error\u reporting
并启用
display\u errors
如下:对于8000条记录,其行为与以前一样…(空白页)对于4000或5000张记录表,如果插入行的数量增加了,请尝试增加
max\u execution\u time
甚至更多(600秒或更多)。如果脚本中没有出现任何错误,那么它一定是
max\u execution\u time
。也请增加远程主机上的
max\u execution\u time
。应该使用相同的参数,如果不是,您可能会联系提供商/主机来修复php.ini中的该设置。在某些情况下,
PHPExcel
会消耗大量内存。请启用详细日志记录和(如果您可以在主机上执行)增加
max\u execution\u time
memory\u limit
。我已经增加了两个参数-execution time n memory limit..但同样的问题请增加
error\u reporting
并启用
display\u errors
如下:对于8000条记录,其行为与以前一样…(空白页)对于4000或5000张记录表,如果插入行的数量增加了,请尝试增加
max\u execution\u time
甚至更多(600秒或更多)。如果脚本中没有出现任何错误,那么它一定是
max\u execution\u time
。也请增加远程主机上的
max\u execution\u time
。应该使用相同的参数,如果不是,您可以联系您的提供者/宿主来修复php.ini中的该设置。
   <?php 
include("../config/dbcon.php"); 


    if(isset($_FILES['clients'])  )
    {
        extract($_POST); 
        $prod=$_FILES['clients']['name'];
        move_uploaded_file($_FILES['clients']['tmp_name'],'dbxsl/'.$prod);
        $exttt= explode(".",$prod);

 if($exttt[1]=="xls")
{
    include 'Excel/reader.php';
        $data = new Spreadsheet_Excel_Reader();
        $data->setOutputEncoding('CP1251');

        $data->read('dbxsl/'.$prod);

                $result = mysql_query("SHOW TABLE STATUS LIKE 'clients'");
                 $row = mysql_fetch_array($result); 
                 $nextId = $row['Auto_increment'];
                 $nextId1 = $row['Auto_increment'];  
    $wRow=array();
    $valid="";
    //echo 'hieee';
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
    {
                    if( $data->sheets[0]['cells'][$i][3] != "")
                    {           if (filter_var($data->sheets[0]['cells'][$i][3],FILTER_VALIDATE_EMAIL) === false)
                                {
                                    if (!in_array($i,$wRow ))
                                    {
                                    $validate.="\n  email id in xl sheet for ".$i."th client is not valid  \r\n ";
                                    $validate.="</br>";
                                    array_push($wRow,$i);
                                    continue 1 ;
                                    }
                                //echo $i;
                                }
                                $email=$edata[$k];                  
                    }
                    $GLOBALS[r_name]=addslashes($data->sheets[0]['cells'][$i][1]);
                    $GLOBALS[area]=addslashes($data->sheets[0]['cells'][$i][6]);
                    $GLOBALS[address]=addslashes($data->sheets[0]['cells'][$i][4]);
                    $sqlval123="select * from clients where Restaurant_Name='$r_name' and area='$area' and address='$address'";
                    $retval = mysql_query( $sqlval123);
                    //echo $sqlval123;
                    if(mysql_num_rows($retval)!=0)
                    {
                        if($r_name!="" and $area!="")
                        {
                            if (!in_array($i,$wRow ))
                             {
            $validate.="Client " .$i." in xl sheet is already exist with name =".strtoupper ($r_name)." and at area ='".$area."' with  address ='".$address. "'</br>";
                                array_push($wRow,$i);
                            }
                        }

                    }

                 if(!in_array($i, $wRow))
                {
                        $sql = "INSERT INTO `clients` (countryid,stateid,cityid,mainid,submainid,Restaurant_Name,contact,email,address,timing,area,hd,dinein,svegnn,bar,aircond,cuisine,knownfor,order_sugest,payment,bank,cost,login,password) VALUES\r\n";

                        $insertrate=mysql_query("Insert into avgrate(client_id,avgrat)values($nextId,'0') ");

                            $sql .= "($count,$state,$city,'','',";
                    $sql .= "'" .  addslashes(trim($data->sheets[0]['cells'][$i][1])) . "','" . addslashes(trim( $data->sheets[0]['cells'][$i][2])) . "','" .addslashes(trim(  $data->sheets[0]['cells'][$i][3])) . "','" .  addslashes(trim($data->sheets[0]['cells'][$i][4] )). "','" . addslashes(trim( $data->sheets[0]['cells'][$i][5] )). "','" . addslashes(trim(  $data->sheets[0]['cells'][$i][6])) . "','" . addslashes(trim(  $data->sheets[0]['cells'][$i][7] )). "','" .   addslashes(trim($data->sheets[0]['cells'][$i][8])) . "','" .  addslashes(trim( $data->sheets[0]['cells'][$i][9])) . "','" . addslashes(trim( $data->sheets[0]['cells'][$i][10])) . "','" . addslashes(trim( $data->sheets[0]['cells'][$i][11])) . "','" . addslashes(trim( $data->sheets[0]['cells'][$i][12] )). "','" . addslashes(trim( $data->sheets[0]['cells'][$i][13])) . "','" . addslashes(trim( $data->sheets[0]['cells'][$i][14])) . "','" .  addslashes(trim($data->sheets[0]['cells'][$i][15] )). "','" . addslashes(trim( $data->sheets[0]['cells'][$i][16])). "','" . addslashes(trim( $data->sheets[0]['cells'][$i][17] )). "',";
                            // INSERT INTO TIMINGS TABLE............................................................................
                            $time_arr=split(",", $data->sheets[0]['cells'][$i][5]);

                        $mon="";
                                    $tue="";$wed="";$thu="";$fri="";$sat="";$sun="";
                            for($k=0;$k<=sizeof($time_arr);$k++)
                            {
                                $time=$time_arr[$k];
                                //echo $time."</br>";
                                if($time!="")
                                    {
                                    //echo "helll";
                                    $time=trim($time);
                                    //echo $time."<br>";
                                        if(strpos(strtolower($time),'mon')!== false)
                                        {
                                                $mon=$time;
                                                //echo $mon;
                                        } if(strpos(strtolower($time),'tue')!== false)
                                        {
                                                $tue=$time;
                                                //echo $tue;
                                        } if(strpos(strtolower($time),'wed')!== false)
                                        {
                                                $wed=$time;
                                        } if(strpos(strtolower($time),'thu')!== false)
                                        {
                                                $thu=$time;
                                        } if(strpos(strtolower($time),'fri')!== false)
                                        {
                                                $fri=$time;
                                        } if(strpos(strtolower($time),'sat')!== false)
                                        {
                                                $sat=$time;
                                        } if(strpos(strtolower($time),'sun')!== false)
                                        {
                                                $sun=$time;
                                        }if($mon=="" && $tue=="" && $wed=="" && $thu=="" && $fri=="" && $sat=="" && $sun=="" )
                                         {
                                                $all=$time;
                                        }
                                    }
                            }
                            if($all=="")
                            {
                $insert21="Insert into timings(client_id,mon,tue,wed,thu,fri,sat,sun,cityid)values($nextId-1,'$mon','$tue','$wed','$thu','$fri','$sat','$sun',$city) ";
                            }
                            else
                            {
                $insert21="Insert into timings(client_id,mon,tue,wed,thu,fri,sat,sun,cityid)values($nextId-1,'$all','$all','$all','$all','$all','$all','$all',$city) ";
                            $all="";
                            }
                            //TIMINGS LOGIC OVER........................................................

                            //BANKS,DISCOUNTS,BANK_CLIENT STARTED...........................................


                            $city_arr=split(",",$data->sheets[0]['cells'][$i][16]);
                        for($k=0;$k<sizeof($city_arr);$k++)
                        {
                            $disc_arr=split("-",$city_arr[$k]);
                            $bank=$disc_arr[0];
                            $disc=$disc_arr[1];
                            if($bank!="")
                            {
                                    $sql2="select * from banks where bank=trim('$bank') and cityid=$city";
                                    $res12 = mysql_query($sql2);
                                    if(mysql_num_rows($res12)==0)
                                    {
                                    $insert1="Insert into banks(bank_id,status,bank,cityid)values('','1',trim('$bank'),$city) ";
                                    if(mysql_query($insert1))
                                    {
                                        echo '<script>alert(trim("$bank"));</script>';
                                    }
                                    //echo $insert1;
                                    }
                                    $sql11="select bank_id from banks where bank='$bank' and cityid=$city";
                                    $res11 = mysql_query($sql11);
                                    $row11= mysql_fetch_array($res11);
                                    $bid=$row11['bank_id'];
                                    $sel=mysql_query("select * from bank_client where bank_id=$bid and client_id=$nextId ");
                                    if(mysql_num_rows($sel)==0)
                                    {$insert2=mysql_query("Insert into bank_client(bank_id,client_id)values($bid,$nextId)");
                                    }
                                    $sql1="select bank_id from banks where bank like '$bank' and cityid = $city ";
                                    //echo $sql1;
                                    $res=mysql_query($sql1);
                                    $datares=mysql_fetch_assoc($res);
                                     $value = array_shift( $datares );
                                    $insert=mysql_query("Insert into discounts (client_id,bank_id,discount)values($nextId,$value,'$disc') ");

                            }
                            //echo $insert2;
                        }
                        $nextId=$nextId+1;

                    //BANKS,DISCOUNTS,BANK_CLIENT OVER...........................................

                    // HOME DELIVERY.......................................................
                    if(strtolower($data->sheets[0]['cells'][$i][7])==strtolower("Home Delivery"))
                    {
                    $data->sheets[0]['cells'][$i][7]=1;
                    }
                    else
                    {
                    $data->sheets[0]['cells'][$i][7]=0;
                    }

                    // DINE IN.......................................................
                    if(strtolower($data->sheets[0]['cells'][$i][8])==strtolower("Dine-In Available"))
                    {
                    $data->sheets[0]['cells'][$i][8]=1;
                    }
                    else
                    {
                    $data->sheets[0]['cells'][$i][8]=0;
                    }


                    // VEG NVEG.......................................................
                    if(strtolower($data->sheets[0]['cells'][$i][9])==strtolower("Serves Veg/Non Veg"))
                    {
                    $data->sheets[0]['cells'][$i][9]=1;
                    }
                    else 
                    {
                    $data->sheets[0]['cells'][$i][9]=0;
                    }


                    // BAR.......................................................
                    if(strtolower($data->sheets[0]['cells'][$i][10])==strtolower("Bar"))
                    {
                    $data->sheets[0]['cells'][$i][10]=1;
                    }
                    else 
                    {
                    $data->sheets[0]['cells'][$i][10]=0;
                    }

                    // AC.......................................................
                    if(strtolower($data->sheets[0]['cells'][$i][11])==strtolower("Air Conditioned"))
                    {
                    $data->sheets[0]['cells'][$i][11]=1;
                    }
                    else 
                    {
                    $data->sheets[0]['cells'][$i][11]=0;
                    }


                    // COUSINES.......................................................
                    $cousines_arr=split(",",$data->sheets[0]['cells'][$i][12]);
                    for($k=0;$k<=sizeof($cousines_arr);$k++)
                        {
                            $cousin=$cousines_arr[$k];
                            if($cousin!="")
                            {
                            $cousin=trim($cousin);
                                $insert1="Insert into cousines(client_id,cousine,cityid)values($nextId,'$cousin',$city) ";
                                //echo $insert1;
                                if(mysql_query($insert1))
                                {
                                    /*echo '<script>alert("cousines Updated.");</script>';*/
                                }
                            }
                        }

                    //MAILING CODE......................................................................................
                    $email_name=$data->sheets[0]['cells'][$i][3];
                            $restaurent_name=$edata[0];
                            $login_name=uniqid();   
                            $password=rand(0,10000);
                        $sql .= "'" . mysql_escape_string($login_name) . "',";                  
                        $sql .= "'" . mysql_escape_string($password) . "',"; 
                        $sql = substr($sql, 0, -1) . ");";
                        //echo $sql;

                        $subject = "Dear ".$restaurent_name.", Here Are your Logon Credentials for Wallet Gravity";
                                    $headers = 'From: WalletGravityLoginCredentials@walletgravity.com' . "\r\n" .
                                                'Reply-To: WalletGravityLoginCredentials@walletgravity.com' . "\r\n" .
                                                'X-Mailer: PHP/' . phpversion();
                                    $headers .= "MIME-Version: 1.0\r\n";
                                    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
                                    $message='<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Register</title>
<body>
You have been registered successfully
</body>
</html>';
            $message=stripslashes($message);
$e=mail($email_name,$subject,$message,$headers);
//echo $sql; exit;
$getdata=mysql_query($sql);
$num=$num+1;            

                }

    }

}
    }
if($num>=1)
{
    if($e="true"){echo '<script>alert("Resturant credentials sent to their email id");</script>';}
    echo '<script> var c='.$num.'; alert(c+" Clients Updated.");</script>';
} 
else
{
    echo "";
}
?>