Hi,

i am trying to store some values into a database, but upon trying to add i am getting a "Column count doesn't match value count at row 1"

i believe i am passing something incorrectly but was hoping someone could point me in the right direction

i have included my code here > http://pastebin.com/JTrXc23V

thanks

Recommended Answers

All 3 Replies

I am experiencing a similar issue. In my particular case, this error exists because I have a column in my DB that is missing in my code somewhere (still trying to track it down). You can also get this error if your INSERTs and VALUES don't match.

There is a mismatch in the columns being listed and the VALUES being inserted make sure that whatever columns you have in $dblist mathc everything you have in the VALUES. If it is too hard to compare create an $sql var that holds the whole sql statement and dump or display that variable soyou can acually see what is being created. You can then copy that to either MySql workbench (or other SQL tool) to help you find the missing column.

Hi $dblist refences my 'listings' table in my database and contains

id
userid
location
user_type
added
updated
expire
user_expire
viewed
images
hide
featured
status
pending
stock
vin
model_year
make
model
cond
category
category2
mileage
mileage_alt
price
sale
price_alt
mot
mot_expire
reg_plate
reg_docs
owners
exterior
interior
doors
fuel
drive
engine
trans
top_speed
horsepower
torque
towing
features
description
tagline
link_url
link_text
ebay_url

the code i use on my page is

$result = mysql_query ('SELECT user_type,expire FROM ' . $dbacct . ' WHERE id=\'' . $_POST['userid'] . '\' LIMIT 1', $link);
        $row = mysql_fetch_array ($result);
        if (!(mysql_query ('INSERT INTO ' . $dblist . ' VALUES(\'0\',
        \'' . $_POST['userid'] . '\',
        \'' . $_POST['location'] . '\',
        \'' . $row['type'] . '\',
        \'' . time () . '\',
        \'' . time () . ('\',
        \'' . $expire . '\',
        \'' . $row['expire'] . '\',
        \'0\',
        \'0\',
        \'' . $_POST['hide'] . '\',
        \'' . $_POST['featured'] . '\',
        \'' . $_POST['status'] . '\',
        \'1\',
        \'' . $_POST['stock'] . '\',
        \'' . $_POST['vin'] . '\',
        \'' . $_POST['model_year'] . '\',
        \'' . $_POST['make'] . '\',
        \'' . $_POST['model'] . '\',
        \'' . $_POST['cond'] . '\',
        \'' . $_POST['category'] . '\',
        \'' . $_POST['category2'] . '\',
        \'' . $_POST['mileage'] . '\',
        \'' . $_POST['mileage_alt'] . '\',
        \'' . $_POST['price'] . '\',
        \'' . $_POST['sale'] . '\',
        \'' . $_POST['price_alt'] . '\',
        \'' . $_POST['exterior'] . '\',
        \'' . $_POST['interior'] . '\',
        \'' . $_POST['doors'] . '\',
        \'' . $_POST['fuel'] . '\',
        \'' . $_POST['drive'] . '\',
        \'' . $_POST['engine'] . '\',
        \'' . $_POST['trans'] . '\',
        \'' . $_POST['top_speed'] . '\',
        \'' . $_POST['horsepower'] . '\',
        \'' . $_POST['torque'] . '\',
        \'' . $_POST['towing'] . '\',
        \'' . $_POST['features'] . '\',
        \'' . $_POST['description'] . '\',
        \'' . $_POST['tagline'] . '\',
        \'' . $_POST['link_url'] . '\',
        \'' . $_POST['link_text'] . '\',
        \'' . $_POST['ebay_url'] . '\')'), $link)))

should i include every field in my database when inserting from my webpage even if i dont want a value in it?

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.