travisb Posted December 9, 2005 Posted December 9, 2005 I have added 18 fields to my products table to keep track of all the different fields for my products. I have everything working except for duplicating the product. I am getting the following error message when hitting the copy to button. 1136 - Column count doesn't match value count at row 1 insert into products (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_year, products_length, products_beam, products_fuel_capacity, products_dead_rise, products_engine_spec, products_horse_power, products_fuel_type, products_num_engines, products_engine_type, products_hours, products_hull, products_stock_num, products_hull_num, products_type, products_max_weight, products_draft, products_water_capacity) values ('0', '', 'images_thumbs/2006_chap_sig_240.jpg', '0.0000', now(), null, '5377.00', '0', '0', '10, 2006, 26\'1\", 8\'6\", 71, 19, Mercruiser 350 MAG MPI, 300, Gasoline, 1, Inboard/Outboard, 0, Fiberglass, 849H506, FGBF1849H506, , , , ') Here is my code for that section: elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') { $product_query = tep_db_query("select products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_year, products_length, products_beam, products_fuel_capacity, products_dead_rise, products_engine_spec, products_horse_power, products_fuel_type, products_num_engines, products_engine_type, products_hours, products_hull, products_stock_num, products_hull_num, products_type, products_max_weight, products_draft, products_water_capacity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $product = tep_db_fetch_array($product_query); tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_year, products_length, products_beam, products_fuel_capacity, products_dead_rise, products_engine_spec, products_horse_power, products_fuel_type, products_num_engines, products_engine_type, products_hours, products_hull, products_stock_num, products_hull_num, products_type, products_max_weight, products_draft, products_water_capacity) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "', now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . ", " .tep_db_input($product['products_year']). ", " .tep_db_input($product['products_length']). ", " .tep_db_input($product['products_beam']). ", " .tep_db_input($product['products_fuel_capacity']). ", " .tep_db_input($product['products_dead_rise']). ", " .tep_db_input($product['products_engine_spec']). ", ". tep_db_input($product['products_horse_power']). ", ". tep_db_input($product['products_fuel_type']). ", " .tep_db_input($product['products_num_engines']). ", " .tep_db_input($product['products_engine_type']). ", " .tep_db_input($product['products_hours']). ", " . tep_db_input($product['products_hull']) . ", " .tep_db_input($product['products_stock_num']). ", " .tep_db_input($product['products_hull_num']). ", " .tep_db_input($product['products_type']). ", " .tep_db_input($product['products_max_weight']). ", " .tep_db_input($product['products_draft']). ", " .tep_db_input($product['products_water_capacity']) . "')"); $dup_products_id = tep_db_insert_id(); $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'"); while ($description = tep_db_fetch_array($description_query)) { tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')"); } tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')"); $products_id = $dup_products_id; } I have checked several times and it looks like I have everything I need. Can someone please help me find the error? Thanks, Travis
kgt Posted December 9, 2005 Posted December 9, 2005 1136 - Column count doesn't match value count at row 1 insert into products (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_year, products_length, products_beam, products_fuel_capacity, products_dead_rise, products_engine_spec, products_horse_power, products_fuel_type, products_num_engines, products_engine_type, products_hours, products_hull, products_stock_num, products_hull_num, products_type, products_max_weight, products_draft, products_water_capacity) values ('0', '', 'images_thumbs/2006_chap_sig_240.jpg', '0.0000', now(), null, '5377.00', '0', '0', '10, 2006, 26\'1\", 8\'6\", 71, 19, Mercruiser 350 MAG MPI, 300, Gasoline, 1, Inboard/Outboard, 0, Fiberglass, 849H506, FGBF1849H506, , , , ') It's telling you the column count (listing of columns) doesn't match value count (listing of values). Let's match them up as you have them in your query: products_quantity -> '0' products_model -> '' products_image -> 'images_thumbs/2006_chap_sig_240.jpg' products_price -> '0.0000' products_date_added -> now() products_date_available -> null products_weight -> '5377.00' products_status -> '0' products_tax_class_id -> '0' manufacturers_id -> '10 //UH OH - no closing quote on that field, so this whole field goes from '10 to the next unescaped apostrophe: '10, 2006, 26\'1\", 8\'6\", 71, 19, Mercruiser 350 MAG MPI, 300, Gasoline, 1, Inboard/Outboard, 0, Fiberglass, 849H506, FGBF1849H506, , , , ' That's all one field, so the next fields are empty: products_year -> products_length -> products_beam -> products_fuel_capacity -> products_dead_rise -> products_engine_spec -> products_horse_power -> products_fuel_type -> products_num_engines -> products_engine_type -> products_hours -> products_hull -> products_stock_num -> products_hull_num -> products_type -> products_max_weight -> products_draft -> products_water_capacity -> You will need quotes around the other fields like 'Mercruiser 350 MAG MPI' too. Contributions Discount Coupon Codes Donations
Recommended Posts
Archived
This topic is now archived and is closed to further replies.