Unexpected T_VARIABLE

I’m getting Parse error: syntax error, unexpected T_VARIABLE error for the following. Can anyone help me sport the unexpected t_variable?

mysql_query("INSERT INTO product (product_id, model, sku, upc, quantity, stock_status_id, manufacturer_id, shipping, price, points, tax_class_id, weight, weight_class_id, length, width, height, length_class_id, subtract, minimum, sort_order, status, date_added, date_modified, viewed) VALUES ("$row[productid]", "$row[product]", "$row[productcode]", "$row[UPC]", "$row[avail]", "7", "$row[manufactureid]", "1", "0.0000", "0", "9", "$row[weight]", "2", "0.00", "0.00", "0.00", "3", "1", "$row[min_amount]", "0", "1", "$row[add_date]", "$row[add_date]", "0")") or die(mysql_error());

dump the double quotes from around your values:
“$row[productid]”
try just $row[productid]… same for all other VALUES

Try this. I removed the double quotes on the $row variables and single quoted the array keys. Also I surrounded each $row with {} and according the netbeans the syntax error is gone. Also All the single string values are single quoted.

In you code you had all the double quotes inside the string unescaped so it was causing it to enter and leave the string without the " . " operator to concatenate the string.


$sql = "INSERT INTO product (product_id, model, sku, upc, quantity, stock_status_id, manufacturer_id, shipping, price, points, tax_class_id, weight, weight_class_id, length, width, height, length_class_id, subtract, minimum, sort_order, status, date_added, date_modified, viewed)";
$sql .= " VALUES ({$row['productid']}, {$row['product']}, {$row['productcode']}, {$row['UPC']}, {$row['avail']}, '7', {$row['manufactureid']}, '1', '0.0000', '0', '9', {$row['weight']}, '2', '0.00', '0.00', '0.00', '3', '1', {$row['min_amount']}, '0', '1', {$row['add_date']}, {$row['add_date']}, '0')";
mysql_query( $sql ) or die( mysql_error() );

One more way to reinforce what ultra1 and Jeremy said:


mysql_query("
	INSERT
		INTO
	product (
	  product_id
	, model
	, sku
	, upc
	, quantity
	, stock_status_id
	, manufacturer_id
	, shipping, price
	, points
	, tax_class_id
	, weight
	, weight_class_id
	, length
	, width
	, height
	, length_class_id
	, subtract
	, minimum
	, sort_order
	, status
	, date_added
	, date_modified
	, viewed
	) VALUES (
	  '". $row['productid'] ."'
	, '". $$row['product'] ."'
	, '". $row['productcode'] ."'
	, '". $row['UPC'] ."'
	, '". $row['avail'] ."'
	, '7'
	, '". $row['manufactureid'] ."'
	, '1'
	, '0.0000'
	, '0'
	, '9'
	, '". $row['weight'] ."'
	, '2'
	, '0.00'
	, '0.00'
	, '0.00'
	, '3'
	, '1'
	, '" . $row['min_amount'] ."'
	, '0'
	, '1'
	, '". $row['add_date'] ."'
	, '". $row['add_date'] ."'
	, '0'
	)
	") or die(mysql_error());