Guest User

Untitled

a guest
Jun 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 KB | None | 0 0
  1. $final = array($pid, $username, $color0, $size0, $qty0, $pid, $username, $color1, $size1, $qty1, $pid, $username, $color2, $size2, $qty2, $pid, $username, $color3, $size3, $qty3, $pid, $username, $color4, $size4, $qty4, $pid, $username, $color5, $size5, $qty5, $pid, $username, $color6, $size6, $qty6, $pid, $username, $color7, $size7, $qty7, $pid, $username, $color8, $size8, $qty8, $pid, $username, $color9, $size9, $qty9);
  2.  
  3. $query = "INSERT INTO product_description(product_id, username, color, size, qty) VALUES";
  4.  
  5. // Loop through the array
  6. for($i = 0, $c = count($final); $i < $c; $i += 3) {
  7. // Add the next batch of values to the query string
  8. $query .= "('{$final[$i]}', '{$final[$i + 1]}', '{$final[$i + 2]}', '{$final[$i + 3]}', '{$final[$i + 4]}', '{$final[$i + 5]}', '{$final[$i + 6]}', '{$final[$i + 7]}', '{$final[$i + 8]}', '{$final[$i + 9]}')";
  9.  
  10. // Add a comma is this is not the last batch
  11. if($i + 3 < $c) {
  12. $query .= ", ";
  13. }
  14. }
  15.  
  16. // Execute the query
  17. $RESULT = mysql_query($query);
  18.  
  19. // Check the results
  20. if($RESULT) {
  21. echo "Query was successfull";
  22. }
  23. else {
  24. echo "Query failed
  25. <blockquote>". $query ."</blockquote>
  26. <blockquote>". mysql_error() ."</blockquote>";
  27. }
  28.  
  29.  
  30. and I'm recieving this error:
  31.  
  32.  
  33. Array ( [0] => [1] => business9 [2] => 1 [3] => 2 [4] => 3 [5] => [6] => business9 [7] => 4 [8] => 5 [9] => 6 [10] => [11] => business9 [12] => 7 [13] => 8 [14] => 9 [15] => [16] => business9 [17] => 10 [18] => 11 [19] => 12 [20] => [21] => business9 [22] => 13 [23] => 14 [24] => 15 [25] => [26] => business9 [27] => 16 [28] => 17 [29] => 18 [30] => [31] => business9 [32] => 19 [33] => 20 [34] => 21 [35] => [36] => business9 [37] => [38] => [39] => [40] => [41] => business9 [42] => [43] => [44] => [45] => [46] => business9 [47] => [48] => [49] => ) Query failed
  34.  
  35. INSERT INTO product_description(product_id, username, color, size, qty) VALUES('', 'business9', '1', '2', '3', '', 'business9', '4', '5', '6'), ('2', '3', '', 'business9', '4', '5', '6', '', 'business9', '7'), ('business9', '4', '5', '6', '', 'business9', '7', '8', '9', ''), ('6', '', 'business9', '7', '8', '9', '', 'business9', '10', '11'), ('7', '8', '9', '', 'business9', '10', '11', '12', '', 'business9'), ('', 'business9', '10', '11', '12', '', 'business9', '13', '14', '15'), ('11', '12', '', 'business9', '13', '14', '15', '', 'business9', '16'), ('business9', '13', '14', '15', '', 'business9', '16', '17', '18', ''), ('15', '', 'business9', '16', '17', '18', '', 'business9', '19', '20'), ('16', '17', '18', '', 'business9', '19', '20', '21', '', 'business9'), ('', 'business9', '19', '20', '21', '', 'business9', '', '', ''), ('20', '21', '', 'business9', '', '', '', '', 'business9', ''), ('business9', '', '', '', '', 'business9', '', '', '', ''), ('', '', 'business9', '', '', '', '', 'business9', '', ''), ('', '', '', '', 'business9', '', '', '', '', ''), ('', 'business9', '', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', '', '', '')
  36.  
  37. Column count doesn't match value count at row 1
Add Comment
Please, Sign In to add comment