Accent problem in mysql and php

Asked

Viewed 160 times

0

I have a problem with accentuation in my database. I’ve done a lot of research on this, I’ve done a lot of tests and nothing.

This is what happens:

My database is already "utf8_unicode_ci" I made a simple test to register a name as "gê" the tables are accepting normally.

The problem is when I do this from my user registration file. The result in the table is as follows: "Gê"

My php connection to the database is like this:

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 format latin1_swedish_ci also and nothing

  • Gê, you also need to evaluate the encoding of your file and encoding that the file is being instructed, either by html or php.

  • 1

    There is no way your database is "utf8_unicode_ci", this is collation. You should not confuse collation with charset (the ideal is for the two to be compatible, but they are not the same thing). Also, you have to test if the application is sending data in UTF-8 (and this has nothing to do with the code posted).

No answers

Browser other questions tagged

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