将几个数组中的数据插入mysql数据库中的相应字段

My code did work when I was using mysql, now upgrading to mysqli has introduced problems. I have several interger arrays of various length and I am using a for loop of 48 steps to insert the data into the fields of my database. What is happenning is my array that has only 4 elements is causing the whole database insert to stop after the 4 th loop. The process stops with a rejected URL request, which is my page presenting the insert commands.

My code:

$setcomm = array  (1201.30,16.30,3.22,7.98,0.95, 78.78, 54.12,1.45,3.09,62.44,36.95,269.64,
  239.59,6.15,4.57,.43,100.00,.8622,14640,    1.21,  1.55, 1.19,  1.16, 1, 0, 0, 0,  0, 0, 0, 0.2125 );//dec30 2014

 $qk = array (1,1,1,1);


$xmports = array ( 777, 32197, 2534, 2124, 4658, 8943, 9214, 7360, 24020, 14689, 566, 2310, 00.00 ,3780, 10812, 2448, 262, 11557, 11171, 5711, 12740, 26850,  26551, 1818, 2615, 00.00, 00.00);

for($k=0;$k<48;$k++)

{   

$sqli = ( " INSERT INTO $mr (comm, qrt, trade, gross, interest, coffer) VALUES ( $setcomm[$k], $qk[$k], $xmports[$k], $GDP[$k], $bratz[$k], $fiscal[$k] )  ");



$stone=mysqli_query($connect2, $sqli);

}

I have check your code. It looks fine. You must have to check one thing that is:-

  • You are using three arrays as you mention in you question & array $qk having 4 elements. So can you make 'qrt' column default value NULL in your database under table structure. According to me after set default Null value for 'qrt' column it will working fine.

enter image description here

Set Default value like this in your database table. Please note it is just an example so if you know which fields always get a value for that there is no need to set Default Null Value.