Reputation: 1812
I am updating 8000 records in my database from tab separated .txt
file. My code is updating only first 5506 records and after it terminates without any error. Next time when I refresh the page it updates 5500 records. I didn't make any change in code. Where I am missing? My code is:
$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;
}
Upvotes: 0
Views: 98
Reputation: 2956
Reset your maximum execution time as it seems your program executing for quite long time and check if there is any infinite loop in your code,if it is than remove it.
ini_set('max_execution_time', 600); //600 seconds = 10 minutes
Upvotes: 0
Reputation: 74
You can try enabling display_errors by adding this code to the top of your script:
ini_set('display_errors', 1);
error_reporting(E_ALL);
If this doesnt help you can check your php error logs.
Upvotes: 1