Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It looks to me as if you are mapping your array the wrong way round. You're trying to add two records with six fields each, but what you're actually putting into the SQL statement are six records with two fields each.</p> <p>This is why MySQL is complaining -- because you've told it you want to update six fields, but in each of the records you've given it, you've only specified two fields.</p> <p>You need to build your array differently.</p> <p>I assume that <code>$docno1</code>, <code>$serialno</code>, <code>$acc_name</code>, <code>$debit</code> and <code>$credit</code> will always all have the same number of array elements (it appears from your code that you are assuming this, so I'll follow you in your assumption).</p> <p>In that case, you need to build your array something like this:</p> <pre><code>$multi = array(); foreach($docno1 as $key=&gt;value) { $multi[] = array( $docno1[$key], $serialno[$key], //Array for a row of fields $acc_name[$key], $debit[$key], $credit[$key], $docno1[$key]) } </code></pre> <p>Replace the block in your code where you set <code>$multi</code> with this, and your program should work.</p> <p>Look at what <code>print_r($multi)</code> looks like now, and you'll see the difference.</p> <p>(note, there are more efficient ways of writing your whole program than this, but I've focused on giving you a drop-in replacement for this specific bit, to help show you where you were going wrong, rather than simply rewriting the whole program for you)</p> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload