0

I have researched a lot about it, I made many tests and no success.

Here's what happens:

My database is now "utf8_unicode_ci". I did a simple test to register a name as "Gê" and the tables are accepting normally.

The problem is when I do it from my RegisterUser php file. The results in the table is this: Gê

My php connection with the database is:

public function openConnection() { 
    $this->conn = new mysqli($this->dbhost, $this->dbuser, $this->dbpass, $this->dbname);
    $this->conn->set_charset("utf8");
    if (mysqli_connect_errno()){
        throw new Exception("Could not establish connection with database");
    }
}

PS: I've tried the latin1_swedish_ci format

Edit:

I fixed this using the following htmlentities: $username = html_entity_decode($_POST["username"], ENT_QUOTES, "ISO-8859-5");

  • How did you end up with `Gê`? That is an entity, if this was a character encoding issue you would end up with the multibyte character broken into single byte characters and misrepresented. You must be encoded to entities somewhere. Make sure you are viewing the actual source and not browser rendering.. – chris85 May 10 '16 at 21:11
  • 1
    If you want the character, not the entity in your database you're going to need to decode the entity and update the db. I don't think this is a dup. Issue is `Gê` is outputting as `Gê`, not a utf8 issue. – chris85 May 10 '16 at 21:16
  • 1
    `ê` is an "html entity". MySQL does not know anything about such; to MySQL, it is just 7 characters. Something else generated the "entity". – Rick James May 10 '16 at 22:20
  • No, this is not a duplicate of "UTF-8 all the way through", though that is a good thread. This has to do with entities. – Rick James May 10 '16 at 22:21
  • 1
    The problem is *most likely* that the browser is sending the data as HTML entity, because it has not been properly instructed to use UTF-8. This *is* covered within [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through). – deceze May 11 '16 at 03:45
  • Like @RickJames said this has to do with entities so i fixed on PHP. Thanks everybody. – Henrique Medina May 13 '16 at 00:52
  • I fix this using the following htmlentities: $username = html_entity_decode($_POST["username"], ENT_QUOTES, "ISO-8859-5"); – Henrique Medina Jul 17 '17 at 00:21

0 Answers0