Hi All,
I have an app that uploads a csv file and allocates it’s contents to some fields and then saves them to a table.
It saves the records to the table OK, but I get an error message that states there is 4 offset errors some being :1 and others :2
I have no idea where I have gone wrong (maybe forest for the trees sort of thing)
Here is the code that uploads and saves the data
if ({bank_code} == 0){
// do nothing
}else{
$cnt=0;
$handle = fopen({csv_file},"r");
if ($handle)
{
set_time_limit(0);
//loop through one row at a time
while (($data = fgetcsv($handle, 4096, ',')) !== FALSE)
{
$date_check = $data[{date_col}-1];
// check for single day digits
if ($date_check[1] == '/'){
$date_check = '0'.$date_check;
//echo $date_check;
}
$_date = sc_date_conv($date_check,"dd/mm/yyyy","db_format");
$_amount = ABS($data[{amount_col}-1]);
if ($data[{amount_col}-1] < 0) {
$_drcr = 1;
}else{
$_drcr = -1;
}
if ($data[{amount_col}-1] < 0) {
$_type = 1;
}else{
$_type = 0;
}
$_payee = $data[{ref_col}-1];
$_bank = {bank_code};
$_not_balanced = 1;
$stm ="INSERT INTO temp_transactions (tp_date,tp_amount,tp_payee,tp_drcr,tp_bank,tp_type,tp_not_balanced)
VALUES ('{$_date}',{$_amount},'{$_payee}',{$_drcr},{$_bank},{$_type},{$_not_balanced})";
sc_exec_sql($stm);
$cnt++;
}
fclose($handle);
}
[count_imported] = $cnt;
}
sc_redir('form_temp_transactions',,"_parent");
I also have attached the error message - the program stops before the sc_redir as that app is never started only the error message
Thanks
Tony
