Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter messing up é's
#4

[eluser]Sumon[/eluser]
From PHP bug list: http://bugs.php.net/bug.php?id=19570&edit=2

So, use utf8_decode() and utf8_encode() function in your code.

Here is an example code i have written for you. i hope it's helpful for you

db_schema
Code:
CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(100) character set utf8 collate utf8_unicode_ci NOT NULL,
  `email` varchar(100) character set utf8 collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`id`)
)

Controller test
Code:
function reg_user()
{
    $this->load->helper('form');
    if($_POST)
    {
        echo $_POST['username']."<br>";
        $this->load->model('test_model');
        $id = $this->test_model->insert_user($_POST);

        $user_data = $this->test_model->get_user($id);
        echo utf8_decode($user_data['name']);
    }
    $this->load->view('reg_user_view');
}

Model test_model
Code:
function insert_user()
{
    extract($_POST);
    $this->db->set('name', utf8_encode($username));
    $this->db->set('email', $email);
    $this->db->insert('users');
    return $this->db->insert_id();
}

view reg_user_view.php
Code:
&lt;?php echo form_open('test/reg_user'); ?&gt;
  username :&lt;input name="username" type="text" maxlength="255" size="60" value="" /&gt; <br />
  email :&lt;input name="email" type="text" maxlength="255" size="60" value="" /&gt; <br />
  &lt;input type="submit" name="submit" value="submit"&gt;
  &lt;/form&gt;


Messages In This Thread
CodeIgniter messing up é's - by El Forum - 09-28-2008, 07:45 AM
CodeIgniter messing up é's - by El Forum - 09-30-2008, 11:41 AM
CodeIgniter messing up é's - by El Forum - 09-30-2008, 01:19 PM
CodeIgniter messing up é's - by El Forum - 09-30-2008, 01:25 PM
CodeIgniter messing up é's - by El Forum - 09-30-2008, 01:27 PM
CodeIgniter messing up é's - by El Forum - 10-01-2008, 02:24 AM
CodeIgniter messing up é's - by El Forum - 10-01-2008, 02:29 AM
CodeIgniter messing up é's - by El Forum - 10-01-2008, 02:33 PM
CodeIgniter messing up é's - by El Forum - 10-01-2008, 03:20 PM
CodeIgniter messing up é's - by El Forum - 10-02-2008, 07:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB