column count doesn't match value count at row 1

$objhelperClass->insert(PRODUCT,"catid,subcat,pname,price,sort_order,description","'".$_POST['cat']."','".$_POST['subcat']."','".$_POST['pname']."','".$_POST['amount']."','".$_POST['sort']."'");

$m=$objhelperClass->select(PRODUCT,"1","max(`id`)");
$pid=$m['max(`id`)'];

if(is_array($patas))
{
        foreach(array_combine($patas,$thumbs) as $val => $val1)
        {
            //echo $val;
            $objhelperClass->insert(IMAGES," `image`,`thumb`,`pid`,`link` ","'".$val."','".$val1."','".$pid."' ");
        }
}

Recommended Answers

All 3 Replies

That error means you haven't listed your columns correctly and you're trying to insert more or less fields than you have specified columns.
You list image, thumb, pid and link as columns but have only listed $val, $avl1 and $pid to match them.

ok thanks for the reply but can you tell me how to procees as I am new to this

Simply make sure that for each column you have listed as a target you have a corrsponding value being entered. As a basic SQL example, this won't work:

UPDATE products(col1, col2, col3, col4) VALUES('1','2','3');

because a value is missing for one of the specified columns. In your example I pointed you to the missing $link variable.

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.