PHP 在更新记录时程序异常终止


PHP abnormal termination of program while updating records

我正在从制表符分隔.txt文件中更新数据库中的 8000 条记录。我的代码只更新前 5506 条记录,然后终止没有任何错误。下次刷新页面时,它会更新 5500 条记录。我没有对代码进行任何更改。我在哪里失踪?我的代码是:

$result = mysqli_query($con,"SELECT id FROM `TABLE 1` ");
    for($i=1;$i<=$rows;$i++)
    {
        $flag=0;
       //$result = mysqli_query($con,"SELECT id FROM `TABLE 1` ");
    try
    {
       while($row = mysqli_fetch_array($result))
       {
         //echo $cols[$i][0];
            $v=strval($cols[$i][0]);
            if(strcmp($row['id'],$v)==0)//id exists in database=> update
            {
                echo "update";
                 echo "<br>".$row['id']."  ".$cols[$i][0];
                //echo "<br>".$row['price']."  ".$cols[$i][4];
                //echo"<br> ".$cols[$i][4];
                $uq="UPDATE `TABLE 1` SET `condition`='".$cols[$i][3]."',`price`='".$cols[$i][4]."',`availability`='".$cols[$i][5]."',`link`='".$cols[$i][6]."',`image_link`='".$cols[$i][7]."',`Gender`='".$cols[$i][11]."',`size`='".$cols[$i][13]."',`Color`='".$cols[$i][14]."',`material`='".$cols[$i][15]."',`shipping_weight`='".$cols[$i][16]."' where `id`='$v'";
                //mysqli_query($con,"UPDATE `TABLE 1` SET `price`='".$cols[$i][4]."'  WHERE `id`='$v'");
                //echo $cols[$i][0];
                $d=mysqli_query($con,$uq);
                if($d)
                {
                   echo"updated sucessfully";
                }
                else
                {
                    echo"not inserted";
                   die('Error:'. mysqli_error($con));
                }

            $flag=1;
            break;
           } 
        }     
    }
        catch(Exception $e)
            {
               echo $e->getMessage();
               $flag=1;
            }

您可以尝试通过将以下代码添加到脚本顶部来启用display_errors:

ini_set('display_errors', 1);
error_reporting(E_ALL);

如果这没有帮助,您可以检查您的 php 错误日志。

重置您的最大执行时间,因为您的程序似乎执行了很长时间,并检查您的代码中是否有任何无限循环,如果是,请将其删除。

ini_set('max_execution_time', 600); //600 seconds = 10 minutes