I just noticed that one of the fields in the SQL was out of order, which is close to where it was saying:
error message : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '', '-500', '0', 'Gregory')' at line 2
Can you update your code below and let me know if it works:
function add_bank_trans($type, $trans_no, $bank_act, $ref, $check_no, $source_ref, $date_,
$amount, $person_type_id, $person_id, $currency="", $err_msg="", $rate=0)
{
$sqlDate = date2sql($date_);
// convert $amount to the bank's currency
if ($currency != "")
{
$bank_account_currency = get_bank_account_currency($bank_act);
if ($rate == 0)
$to_bank_currency = get_exchange_rate_from_to($currency, $bank_account_currency, $date_);
else
$to_bank_currency = 1 / $rate;
$amount_bank = ($amount / $to_bank_currency);
}
else
$amount_bank = $amount;
$amount_bank = round2($amount_bank, user_price_dec());
$sql = "INSERT INTO ".TB_PREF."bank_trans (type, trans_no, bank_act, ref, check_no, source_ref,
trans_date, amount, person_type_id, person_id) ";
$sql .= "VALUES ($type, $trans_no, '$bank_act', ".db_escape($ref).", ".db_escape($check_no).", ".db_escape($source_ref).", '$sqlDate', ".db_escape($amount_bank).", ".db_escape($person_type_id).", ". db_escape($person_id).")";
if ($err_msg == "")
$err_msg = "The bank transaction could not be inserted";
db_query($sql, $err_msg);
}
If not, I will try something on my development system.