数据编码不正确

时间:2016-02-27 10:38:28

标签: php codeigniter utf-8 odbc filemaker

让我先详细说明我目前的设置:

Windows 10运行IIS 10,PHP 5.6, 启用了ODBC的FileMaker Server 14

我正在使用CodeIgniter 3.0.4并且配置为使用utf8编码我的odbc dsn设置为使用utf8,我没有任何问题显示“Á”或“ñ”等字符,问题来了插入我的数据时。

// DATA ARRAY
$data = array(
            "id" => null,
            "idPregunta" => (int)$idPreg,
            "idEntrevistado" => $entrevistado,
            "Valor" => "íóú",
            "FechaCreacion" => $fecha
            );


// MODEL SCRIPT
$this->db->insert("Respuesta", $data);

正确显示$sql = $this->db->set($data)->get_compiled_insert('Respuesta');表示我插入的数据是我写的,但在我的数据库中插入的内容如íóú。在数据库中不是问题,使用FileMaker Pro直接插入此字符不会显示相同的编码问题。

配置/ database.php中

$db['default'] = array(
'dsn'   => 'encuestas',
'hostname' => 'localhost',
'username' => 'IIS',
'password' => '123456',
'database' => 'PollServiceSurveys',
'dbdriver' => 'odbc',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

修改

ODBC驱动程序似乎存在问题,快速解决方法是先使用htmlentitieshtmlspecialchars剥离html标记。

0 个答案:

没有答案
相关问题