0

i have upgrade php 5.6 to php7 and same database value . then i use pdo and old mysql connection remove from my code . In my old php version file i used

mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'");

this after mysql_db_connect then all page working perfect in special character . but when update to php 7 using pdo then some special character not working perfectly as like

 Körner

i have added this code in pdo connection file

        $this->PDO = new PDO('mysql:host=' . DBSERV . ';dbname=' . DBNAME . ';charset=utf8', DBUSER, DBPASS);
        $this->PDO->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8' COLLATE 'utf8_general_ci'");
        $this->PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);

i want to solve this issue using this

$this->PDO->setAttribute 
htmlentities()

this type function and database set uft-8 . and in html main file

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

this also set

Shafiqul Islam
  • 5,570
  • 2
  • 34
  • 43

0 Answers0