Hi,
in my Raspberry 3 (raspbian 10 buster) I'm using CodeIgniter (3.1.9) connected to a MS SQL Server via FreeTDS.
If I save a string containing special chars, they are transformed.
For example this string "
Pipe 1m Ø30 cm. max. temp 90 °C" is saved as "Pipe 1m Ø30 cm. max. temp 90 °C"
CodeIgniter sample code:
PHP Code:
$DB = $this->load->database($MSSQL_DB, true);
$desc = "Pipe 1m Ø30 cm. max. temp 90 °C"
$sql = "INSERT INTO MYTABLE (ID, DESC) VALUES (1, '$desc')";
$result= $DB ->query($sql);
In php.ini tried to set default_charset = "" but nothing changed.
How can I solve the problem, avoiding that special characters are changed?
Database collaton is Latin1_General_CI_AS and can't be changed.
Here are some configurations:
Header:
Code:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
CodeIgniter database.php:
Code:
$db['MYDB'] = array(
'dsn' => 'DRIVER=FreeTDS;SERVER=.....;Database=MYDB;UID=myUser;PWD=myPWD;TDS_Version= Auto;Port=1433;',
'hostname' => '',
'username' => '',
'password' => '',
'database' => '',
'dbdriver' => 'odbc',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'char_set' => 'utf8',
'cache_on' => FALSE
);
/etc/freetds/freetds.conf
Code:
[MYSERVER]
host = 192.168.1.200
port = 1433
tds version = 7.2 # 7.2 seems to be the maximum allowed
client charset=UTF-8
/etc/odbcinst.ini
Code:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/arm-linux-gnueabihf/odbc/libtdsodbc.so
Setup=/usr/lib/arm-linux-gnueabihf/odbc/libtdsS.so
FileUsage=1
dontdlclose=1
UsageCount=1
/etc/odbc.ini
Code:
[MYDB]
Description = Database demo MYDB
Driver = FreeTDS
Database = MYDB
Servername = MYSERVER
Port = 1433
Thanks a lot