0

Hi,

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 ***/
		$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

		/*** 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 ***/
		$done->execute();

Thanks for your help.

QWaz

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sourcebits
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.