ianhaney Posted May 5, 2013 Share Posted May 5, 2013 HiI added extra fields following the link belowhttp://www.webidsupport.com/forums/s...ight=conditionI get the following error after pressing submitAn unexpected error occurred. The error has been forwarded to our technical team and will be fixed shortlyI checked the error log just now in admin ->tools and has the followingFord Mondeo', '', 198, 0, '299', '0', '0', '299', '1', '1','1', '2', 'Array', 'Silver', '3', '2', '1', '0', '2', '1', 0, '1367774117', 0, 0, 1, 1, 0, 0, 0, 0, 'n', '', 'y', 'n', 'n', 'n', 0.00)Column count doesn't match value count at row 1page:/home/sites/247autotrade.com/public_html/sell.php line:108I found it is because I have a field short in the coding I am guessing as also found out there are more database columns than there are values, is that right? if so just unsure how to correct itI have been trying to fix it for ages but can't seem to do itIs it to do with the coding below return "INSERT INTO " . $DBPrefix . "auctions VALUES (NULL, " .$user->user_data['id'] . ", '" . $system->cleanvars($_SESSION['SELL_title']) . "', '" . $system->cleanvars($_SESSION['SELL_subtitle']) . "', '" . $a_starts . "', '" . addslashes($_SESSION['SELL_description']) . "', '" . $system->cleanvars($_SESSION['SELL_pict_url']) . "', " . $_SESSION['SELL_sellcat1'] . ", " . intval($_SESSION['SELL_sellcat2']) . ", '" . $system->input_money(($_SESSION['SELL_buy_now_only'] == 'n') ? $_SESSION['SELL_minimum_bid'] : $_SESSION['SELL_buy_now_price']) . "', '" . $system->input_money($_SESSION['SELL_shipping_cost']) . "', '" . $system->input_money(($_SESSION['SELL_with_reserve'] == 'yes') ? $_SESSION['SELL_reserve_price'] : 0) . "', '" . $system->input_money(($_SESSION['SELL_with_buy_now'] == 'yes') ? $_SESSION['SELL_buy_now_price'] : 0) . "', '" . $_SESSION['SELL_atype'] . "', '" . $_SESSION['SELL_condition'] . "', '" . $_SESSION['SELL_make'] . "', '" . $_SESSION['SELL_model'] . "', '" . $_SESSION['SELL_number_doors'] . "', '" . $_SESSION['SELL_colour'] . "', '" . $_SESSION['SELL_year'] . "', '" . $_SESSION['SELL_fuel_type'] . "', '" . $_SESSION['SELL_duration'] . "', '" . $system->input_money($_SESSION['SELL_customincrement']) . "', '" . $_SESSION['SELL_shipping'] . "', '" . $payment_text . "', " . (($_SESSION['SELL_international']) ? 1 : 0) . ", '" . $a_ends . "', 0, 0, " . (($_SESSION['SELL_file_uploaded']) ? 1 : 0) . ", " . $_SESSION['SELL_iquantity'] . ", 0, " . intval($_SESSION['SELL_relist']) . ", 0, 0, 'n', '" . $system->cleanvars($_SESSION['SELL_shipping_terms']) . "', '" . $_SESSION['SELL_buy_now_only'] . "', '" . $_SESSION['SELL_is_bold'] . "', '" . $_SESSION['SELL_is_highlighted'] . "', '" . $_SESSION['SELL_is_featured'] . "', " . $fee . ")"; } Thank you in advance Kind regards Ian Quote Link to comment https://forums.phpfreaks.com/topic/277648-php-error-column-issue/ Share on other sites More sharing options...
mac_gyver Posted May 5, 2013 Share Posted May 5, 2013 when you don't list the column names in the INSERT query, you must supply a value for every column in the table and they must be in the same order that the columns are defined in the table. it is always best to list the column names - INSERT INTO your_table (list of columns) VALUES (list of values) you only need to list the column names you are inserting values for (non-listed columns get their default values/auto increment value) and only the order of the listed columns and listed data must match each other (you don't need to know what the actual order is in the table definition.) for a complex query (with more than a few columns/values) it is easier to see what the query is by using the sprintf() to build the query in a php variable - $query = sprintf("INSERT INTO your_table (col1,col2,col3,...) VALUES ('%s',%d,'%s', ...)", $some_string_value, $some_integer_value, $someother_string_value); you can then echo the $query variable to see exactly what the query statement is. Quote Link to comment https://forums.phpfreaks.com/topic/277648-php-error-column-issue/#findComment-1428381 Share on other sites More sharing options...
ianhaney Posted May 5, 2013 Author Share Posted May 5, 2013 Hmm not sure how I would convert the following to the way you said return "INSERT INTO " . $DBPrefix . "auctions VALUES (NULL, " .$user->user_data['id'] . ", '" . $system->cleanvars($_SESSION['SELL_title']) . "', '" . $system->cleanvars($_SESSION['SELL_subtitle']) . "', '" . $a_starts . "', '" . addslashes($_SESSION['SELL_description']) . "', '" . $system->cleanvars($_SESSION['SELL_pict_url']) . "', " . $_SESSION['SELL_sellcat1'] . ", " . intval($_SESSION['SELL_sellcat2']) . ", '" . $system->input_money(($_SESSION['SELL_buy_now_only'] == 'n') ? $_SESSION['SELL_minimum_bid'] : $_SESSION['SELL_buy_now_price']) . "', '" . $system->input_money($_SESSION['SELL_shipping_cost']) . "', '" . $system->input_money(($_SESSION['SELL_with_reserve'] == 'yes') ? $_SESSION['SELL_reserve_price'] : 0) . "', '" . $system->input_money(($_SESSION['SELL_with_buy_now'] == 'yes') ? $_SESSION['SELL_buy_now_price'] : 0) . "', '" . $_SESSION['SELL_atype'] . "', '" . $_SESSION['SELL_condition'] . "', '" . $_SESSION['SELL_make'] . "', '" . $_SESSION['SELL_model'] . "', '" . $_SESSION['SELL_number_doors'] . "', '" . $_SESSION['SELL_colour'] . "', '" . $_SESSION['SELL_year'] . "', '" . $_SESSION['SELL_fuel_type'] . "', '" . $_SESSION['SELL_duration'] . "', '" . $system->input_money($_SESSION['SELL_customincrement']) . "', '" . $_SESSION['SELL_shipping'] . "', '" . $payment_text . "', " . (($_SESSION['SELL_international']) ? 1 : 0) . ", '" . $a_ends . "', 0, 0, " . (($_SESSION['SELL_file_uploaded']) ? 1 : 0) . ", " . $_SESSION['SELL_iquantity'] . ", 0, " . intval($_SESSION['SELL_relist']) . ", 0, 0, 'n', '" . $system->cleanvars($_SESSION['SELL_shipping_terms']) . "', '" . $_SESSION['SELL_buy_now_only'] . "', '" . $_SESSION['SELL_is_bold'] . "', '" . $_SESSION['SELL_is_highlighted'] . "', '" . $_SESSION['SELL_is_featured'] . "', " . $fee . ")"; } Quote Link to comment https://forums.phpfreaks.com/topic/277648-php-error-column-issue/#findComment-1428458 Share on other sites More sharing options...
mac_gyver Posted May 6, 2013 Share Posted May 6, 2013 what have you tried? just posting your query again shows nothing. you either need to make sure you are suppling a value for every column in the table (your existing query method) or you must list the columns you are supplying values for (the suggested query method.) since we don't know what the original columns were, what column(s) you added, where in the existing column order you added it(them), or even which of the values shown are for the added column(s), we cannot help you with this straight-forward task. this is something that you need to do. something tells me that you added column(s) to the table but didn't add any corresponding values to the query. that's only about 1/10 the amount of work needed to add a field of data. btw - the link in the first post in this thread that you copy/pasted from the other forum you posted this in is broken since only the visible text was copy/pasted. Quote Link to comment https://forums.phpfreaks.com/topic/277648-php-error-column-issue/#findComment-1428513 Share on other sites More sharing options...
ianhaney Posted May 6, 2013 Author Share Posted May 6, 2013 (edited) I have attached images of how I entered the fields in the database table see images below And to do it as the way you said $query = sprintf("INSERT INTO your_table (col1,col2,col3,...) VALUES ('%s',%d,'%s', ...)", $some_string_value, $some_integer_value, $someother_string_value); $query = sprintf("INSERT INTO webid_auctions (make,model,number_doors,...) VALUES ('%make',%model,'%number_doors', ...)", $some_string_value, $some_integer_value, $someother_string_value); Would that be right? I was thinking of something like the following Edited May 6, 2013 by ianhaney Quote Link to comment https://forums.phpfreaks.com/topic/277648-php-error-column-issue/#findComment-1428530 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.