1

I'm having some errors in my MySQL with accents, all my files are in UTF-8.

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

But still not work, it just work if I place this after the MySQL Connection:

mysqli_query($conn,'SET character_set_results=utf8');

I have multiples functions that starts a new connection, so need to add for every one, its a problem.

My database are all in UTF-8 format.

5
  • what's the error? and where is the rest of your code? Commented Oct 2, 2018 at 1:45
  • setup a function for it and pass the connection to it as an additional parameter. Or look into using OOP. You'd have to show us what those functions are and how you're including all these files, if there are many. The question's unclear for me. Commented Oct 2, 2018 at 1:46
  • 4
    Possible duplicate of UTF-8 all the way through Commented Oct 2, 2018 at 1:52
  • The error that appears ? instead of tildes like Vélcis it appears V?lcis Commented Oct 2, 2018 at 1:58
  • that's not an error, it's just not showing you what it should be due to a few possible reasons that can be found in the link that was left above about the duplicate. Read through that and you might very well find your solution. @user3811313 Commented Oct 2, 2018 at 2:13

2 Answers 2

2

After your mysqli_connect line use mysqli_set_charset($conn,"utf8"); and it will set to to every of yours connection.

Sign up to request clarification or add additional context in comments.

7 Comments

The problem is, each function have a new mysqli_connect() so many things to edit.
Are all your $conn the same host, user, password, and database?
Yes, but it doesn't work outside class connection, than I need to set every class one connection.
Controle find + replace would take 30 seconds right?
unfortunately not, instead of classes a lot of files have $conn inside. My DB is already on UTF8, all my files stills UTF8 and nothing :/
|
0

try mysqli_set_charset($conn,'utf8')

$conn = mysqli_connect("host","username","password") or 
die(mysqli_error($conn));
mysqli_set_charset($conn,'utf8');
mysqli_select_db($conn,'databasename') or die("cannot select DB");

1 Comment

As I said, this is the only way to work, but I have one new connection in each class of my app, so need to add one by one. :x

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.