I am using some code that I use pretty much most of the time for every insert.
However now I am getting this error and have no idea why this is happening.

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'NULL' in 'field list'

My code is below.

$id = NULL;
		$offer = $_POST['negOffer'];
		$accepted = '0';
		$counter = '1';
		$in_neg = '1';
		$in_cart = '0';
		$paid = '0';
		$removed = '0';
		$timeStamp = time();
		/*** connect to db ***/
		$conn = dbConnect('admin');

		/*** set the error mode ***/

		/*** our sql query ***/
		$done = $conn->prepare("INSERT INTO `".$user."` (`id`, `product_id`, `offer`, `accepted`, `counters`, `in_neg`, `in_cart`, `paid`, `removed`, `initial_timestamp`) VALUES (`?`,`?`,`?`,`?`,`?`,`?`,`?`,`?`,`?`,`?`)");

		/*** bind the params ***/
		$done->bindParam(1, $id);
		$done->bindParam(2, $productID);
		$done->bindParam(3, $offer);
		$done->bindParam(4, $accepted);
		$done->bindParam(5, $counter);
		$done->bindParam(6, $in_neg);
		$done->bindParam(7, $in_cart);
		$done->bindParam(8, $paid);
		$done->bindParam(9, $removed);
		$done->bindParam(10, $timeStamp);

		/*** execute the query ***/

Thanks for your help.


you may post the table structure, to be more clear on. You may test without using PDO mysql and see what is the error.

Be a part of the DaniWeb community

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