Jump to content

Recommended Posts

Hi

I added extra fields following the link below

http://www.webidsupport.com/forums/s...ight=condition

I get the following error after pressing submit

An unexpected error occurred. The error has been forwarded to our technical team and will be fixed shortly

I checked the error log just now in admin ->tools and has the following

Ford 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 1
page:/home/sites/247autotrade.com/public_html/sell.php line:108

I 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 it

I have been trying to fix it for ages but can't seem to do it

Is 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

 

Link to comment
https://forums.phpfreaks.com/topic/277648-php-error-column-issue/
Share on other sites

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.

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 . ")";   
}

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.

I have attached images of how I entered the fields in the database table

 

see images below

 

sqlone.png

 

sqltwo.png

 

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 by ianhaney
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.