Error handling of special characters when sending to iso-88591 and utf-8 database

Asked

Viewed 34 times

0

Good evening friends,

I have a problem where I can’t send data correctly to the database, when this data goes with special characters, name like D'vila always give errors.

Has anyone ever had this problem or knows any solution.

follows the codes of the model where the shipment is made to the bank. I used this htmlentities to address the ' issue, but when I fetch the data to show in the view there are visualization errors.

function register_doctor($data)
{

        $key = $this->config->item('encryption_key');

        if($this->db->insert('tbl_doctors', $data))
        {

            $insertid = $this->db->insert_id();

            $this->db->query('Update tbl_doctors SET name = AES_ENCRYPT("'.htmlentities($data['name'], ENT_QUOTES).'","'.$key.'"),
                             cpf = AES_ENCRYPT("'.$data['cpf'].'","'.$key.'"),
                             email = AES_ENCRYPT("'.$data['email'].'","'.$key.'"),
                             password = AES_ENCRYPT("'.$data['password'].'","'.$key.'"),
                             profile_pic = AES_ENCRYPT("'.$data['profile_pic'].'","'.$key.'"),
                             username = AES_ENCRYPT("'.$data['username'].'","'.$key.'"),
                             account_status = 0,
                             date_register = AES_ENCRYPT("'.date('Y-m-d').'","'.$key.'")
                             where id='.$insertid);

            $query = $this->db->get_where("tbl_doctors",array("id"=>$insertid))->row_array();

            $return_array = array('status'=>'success','data'=>$query);

        }
        else
        {

            $return_array = array('status'=>'fail');

        }

    return $return_array;

}

The values save so in the bank as dados no banco

and I wanted to save as an example: Jonathas d'vila?

thank you very much :)

1 answer

2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.