i dont see what's wrong.
&# 039; stands for an apostrophe, it's normal for sql query to use apostrophe.
executed in php your query will provide something like :
INSERT INTO 2_sales_orders (order_no, type, debtor_no, trans_type, branch_code, customer_ref, reference, comments, ord_date, order_type, ship_via, deliver_to, delivery_address, contact_phone, freight_cost, from_stk_loc, delivery_date, payment_terms, total) VALUES ('50','0','2', '30','3', '','auto','','2013-11-19', '1', '1','Ventas Al Contado','Km. 15.5 Carretera a Masaya.', '55555555', '0', 'DEF', '2013-11-19','5','2300').
as long as there is no error in the execution of your erp, that should be fine.
you'r talking about x_sql_trail, it's used to store all executed queries, for audit or tracking purposes. if you see it as an issue, you can always modify the function db_query($sql, $err_msg = null) (connect_db.php) to force using an apostrophe instead of &# 039;