Problem reading words from database with accent or cedilla

Asked

Viewed 1,133 times

4

I’m reading my table categories from the database and when I have words with cedilla or accents, they appear in my project with strange characters.

For example, in the categories I have a title Evaluations, in my project this title appears as: AVALIA��ES.

I was researching about this problem and I realized that I had to have in my database the Grouping (Collation) as utf8_general_ci, and also that at the top of my page should contain this goal: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

However, even with these two methods to solve the problem, I still have my title as AVALIA��ES.

Someone knows what might be going on and how I can fix this?

1 answer

6


I propose you do the following:

1 - Insert these lines of code into your database connection file:

mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');

2 - Make sure the database is in UTF-8 format. For this access your database and go to Operations (phpmyadmin) and make sure that your database is storing the information with the right coding.

Put then settle down.

  • 2

    Thank you marcosvinicius. The solution was just that, but in my case I am using Pdo, it has to be like this: array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")

  • 1

    OK I did the above procedure and it worked. congratulations!

  • 1

    Comrade, a lot of trouble. I had this problem here and you helped me a lot.

Browser other questions tagged

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