WHy don't you set up a key-value array and loop it until you hit an error?
Anyway use NULL instead of 'NULL'
You also seem to be using reserved words as fieldnames and you don't backtick them. do this, e.g.
...,`date`,...
If you have a real problem with this, try the following, moving the /* down every time to see when the error (if it exists) appears:
$r = array(
'ID' => NULL,
'category' => 'category',
/* 'quantity' => 'quantity',
'description' => 'description',
'value' => 'value',
'volt' => 'volt',
'current' => 'current',
'tolerance' => 'tolerance',
'power' => 'power',
'wafer' => 'wafer',
't_type' => 't_type',
'package' => 'package',
'case' => 'case',
'tempco' => 'tempco',
'location' => 'location',
'manufacturer' => 'manufacturer',
'date' => NULL,
'datasheet' => 'datasheet',
'reclaimed' => 'reclaimed',
'user'=>NULL,
'code' => 'code',
'rohs' => 'rohs',
'mount' => 'mount',
'material' => 'material',
'esr' => 'esr',
'dimensions' => 'dimensions',
'custom_code' => 'custom_code',
'track_taper' => 'track_taper',
'turns' => 'turns',
'gang' => 'gang' */
);
foreach($r as $fieldname => $value){
$fields[] = "`$fieldname`";
$values[] = (is_null($value)) ? 'NULL' : "'" . $_SESSION[$value] . "'";
}
$fieldlist = implode(",",$fields);
$valuelist = implode(",",$values);
$sql = "INSERT INTO _components ($fieldlist)VALUES($valuelist)";
echo $sql; diafol
Rhod Gilbert Fan (ardav)
Moderator
7,800 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080