I?m, having a problem inserting data into another table in an after insert event…
here is the code…
$insert_table = ‘inventarios’; // Table name
$insert_fields = array( // Field list, add as many as needed
‘codigo’ => “’$producto’”,
‘bodega’ => “’{codigo}’”,
‘existencia’ => “‘0’”,
);
$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . implode(’, ', array_values($insert_fields)) . ‘)’;
sc_exec_sql($insert_sql);
the problem is this code returns a blank value in the $producto variable like it shows in the sql generated bellow:
INSERT INTO inventarios (codigo, bodega, existencia) VALUES (’’, ‘56’, ‘0’)
since there is no value to be inserted in the codigo field if returns an error…
if i change the above code to this
$insert_table = ‘inventarios’; // Table name
$insert_fields = array( // Field list, add as many as needed
‘codigo’ => “’.$producto.’”,
‘bodega’ => “’{codigo}’”,
‘existencia’ => “‘0’”,
);
$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . implode(’, ', array_values($insert_fields)) . ‘)’;
sc_exec_sql($insert_sql);
now the value of the php variable appears but since i added the before and after dots it throws an error…
INSERT INTO inventarios (codigo, bodega, existencia) VALUES (’.MA0001.’, ‘59’, ‘0’)
what is wrong or what am i doing wrong?