Windows with php the utf-8 characters are correct and Linux is not? [duplicate]

0

I created pages in php in windows 2012 environment with php (to migrate from asp to php)

The pages in php are:

HTML5 (made in Notpad ++ in UTF-8 encoding)

It has < meta charset="UTF-8" > us head

Mysql accesses: $pdo = new PDO("mysql:host=xxxx.mysql.dbaas.com.br;dbname=xxx; charset=utf8", "login", "senha")

fields in tables = latin1_general_ci

RESULT: Perfect accent and characters in Mysql data and text on pages.

PROBLEM in php Linux :

Transfer the same pages to Linux and access the SAME BD Mysql

And gave ERROR IN ACCENT:

Mysql data with ERROR and other texts in the correct pages

COMPLEMENT

In the meantime: I changed the version to php 7.1 I created a table in Mysql of Linux And the accent is correct.

I consider this matter closed.

    
asked by anonymous 16.12.2017 / 06:13

1 answer

0

I was able to correct the accent:

  

Mysql Table: put in Collation = utf8_unicode_ci

Connection to DB with PDO

$pdo = new PDO("mysql:host=XXX;dbname=XXX; charset=utf8", "XX", "XX", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

Note: This array corrected accent errors.

And now the html texts and DB data are correct.

    
16.12.2017 / 20:51