Codeigniter : Problem inserting accents in Mysql

I'm trying out code igniter, and I came across an error message while trying to insert a new row in my Mysql database.

The text I'm trying to insert is in French, and contains some accents.

Here's my code :

    $data= array(
        'title' => $this->input->post('title'),
        'date' => $this->input->post('date'),
        'mytext' => $this->input->post('mytext')
        );

    $this->db->insert('blog', $data); 

This code seems to work fine (I've inserted a few "test test" entries), but when I try to enter something with accents, for instance "Il était là", I get an error message :

A Database Error Occurred

Error Number: 1366

Incorrect string value: 'xE9tait ...' for column 'mytext' at row 1

I've looked on the code igniter forums for a fix, but all they say is to change the collation to UTF8, in mysql. I've tried that, but I keep having the same problem.


在插入数据库之前尝试对其进行编码。

utf8_encode($string)
链接地址: http://www.djcxy.com/p/67816.html

上一篇: 从base64数据字符串

下一篇: Codeigniter:在Mysql中插入重音的问题