I’m trying to insert a number of days into the database, so it can be used as an auction. So when the days are inserted into the database, it pulls those number of days for the item and counts down. This is my query
$sql = "INSERT INTO items_list (item_name, image_path, image_name, item_desc, item_condition, item_quantity, item_notes, item_list_time, list_end, starting_price, user_id) VALUES ('$item_name', '$filePath', '$fileName', '$item_desc','$item_condition', '$item_quantity','$item_notes', NOW() + INTERVAL '.$list_end.' DAY, '$starting_price', '$username')"; Column count doesn't match value count at row 1 when i try to insert it into databaseYou are getting this error because you tried to enter 10 values into 11 columns. Note that mysql requires each value entered is separated by a comma. Look carefully at your entry start from NOW() and ending at DAY, this part is treated as a single value. From what i see, you should separate $NOW +INTERVAL from $list and DAY with a comma. Also, make sure you are using the day function correctly.
A corrected query is shown below: You may use it or make corrections to yours based on the information above
VALUES
(’".$item_name."’, ‘".$filePath."’, ‘".$fileName"’, ‘".$item_desc."’, ‘".$item_condition."’, ‘".$item_quantity."’, ‘".$item_notes."’, ‘".NOW() + INTERVAL"’, '".$list_end."'DAY, ‘".$starting_price."’, ‘".$username."’)";
Or using you method of query
VALUES
(’$item_name’, ‘$filePath’, ‘$fileName’, ‘$item_desc’,’$item_condition’, ‘$item_quantity’,’$item_notes’, NOW() + INTERVAL,’".$list_end.DAY."’, ‘$starting_price’, ‘$username’)";
I haven’t used the DAY function in mysql before but i decided to put it outside the quote in the first example. If this causes problems, simply put a period after DAY and drag it in between the period and double quote after $list end.
Is this all suppose to be one value?
[php]
NOW() + INTERVAL,’".$list_end.DAY."’,[/php]
Since you copied the one i edited i assume i can answer. No they are not one value. As you can see they are separated by a comma. This harmonizes with the tables in the original statement.