0

I would like to fetch the content from a mysql-table to another. The table contains ~312000 rows, only numeric/decimal values with a total size of ~22 MB. The "funny thing": Everything works fine but after writing row 236991 the whole skript stops with an internal server error 500. mysqli_num_rows shows the correct value of 312000 and also my second script (below) works as expected.

PHP 7.0.33 / Mod-PHP / Apache2 / Debian 9

// Stops with an internal Server Error 500  
 $fetch = mysqli_query($connection1,"SELECT `a`,`b`,`c` FROM `table`");
  while($f = mysqli_fetch_array($fetch,MYSQL_ASSOC)) {
  mysqli_query($connection2,"INSERT INTO `table` (a,b,c) VALUES ('$f[a]','$f[b]','$f[c]')");
}

// Works perfect
$val = 0;
$fetch = mysqli_query($connection1,"SELECT `a`,`b`,`c` FROM `table`");
 while($f = mysqli_fetch_array($fetch,MYSQL_ASSOC)) {
 $val++;
 }
 echo $val; // 312000 the correct result
Christoph
  • 123
  • 1
  • 3
  • 16
  • Maybe check the return value of the INSERT query and if false, display the error using `mysqli_error($connection2)` - could there be a constraint being violated? – MER May 21 '19 at 14:04
  • Why insert the same values multiple times? This can be done with 1 query, and no loop `INSERT INTO \`table\` (a,b,c) select a, b, c from \`table\`` – user3783243 May 21 '19 at 14:15

0 Answers0