Problems with UTF-8 resale Locaweb

Asked

Viewed 224 times

1

I have a project hosted on Ocaweb at resale, php/html are coded correctly in utf-8, because what is html or echo is returning perfectly, but information from the database is not returned correctly with ç,á,é...

Via Heidisql I have tried several procedures of ALTER TABLE for utf8 and general_ci, but none was successfully completed, via Heidi I can observe that there are two types of information of the variables SESSION and GLOBAL, SESSION is correct with utf8, but GLOBAL is latin1 and latin1_swedish_ci.

Information is brought via PDO and the database is Mysql.

Summary, not PHP (everything possible has already been tested) and also not the HTML meta.

Question:

How to modify the information to come in utf8 correctly without utf8_encode gambiarra ?

Is there any way to exchange mysql information, as we do with php.ini in Locaweb ?

  • 1

    Follow the step-by-step, see all the details, something must have been missing: https://answall.com/a/43205/3635

  • William Nascimento, all done as indicated in his answer to another question. Nothing was modified, all the steps were repeated by me exactly as indicated. The accents are working and so on, but it doesn’t work when it is picked up via the database, and it is set as utf8, but only in Session and not in Global (viewed via Heidi).

  • You must have forgotten something, please post what you have. PS: I use Ocaweb.

  • After all the ways were applied, after a delay started to work.. I can’t imagine why.. But it all worked out (: Thanks.

  • Can be cache.

1 answer

-1

Try to configure the PDO for UTF-8 in creating the connection:

conn = new PDO(
    'mysql:host='.$host.'; dbname='.$db,
    $user,
    $senha,
    array(
        PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
    )
);
  • I put "$this->Pdo = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));".. but nothing has changed.

Browser other questions tagged

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