Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $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);
- $query = "INSERT INTO product_description(product_id, username, color, size, qty) VALUES";
- // Loop through the array
- for($i = 0, $c = count($final); $i < $c; $i += 3) {
- // Add the next batch of values to the query string
- $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]}')";
- // Add a comma is this is not the last batch
- if($i + 3 < $c) {
- $query .= ", ";
- }
- }
- // Execute the query
- $RESULT = mysql_query($query);
- // Check the results
- if($RESULT) {
- echo "Query was successfull";
- }
- else {
- echo "Query failed
- <blockquote>". $query ."</blockquote>
- <blockquote>". mysql_error() ."</blockquote>";
- }
- and I'm recieving this error:
- 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
- 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', '', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', '', '', '')
- Column count doesn't match value count at row 1
Add Comment
Please, Sign In to add comment