PDO mysql php accentuation problem

Asked

Viewed 1,795 times

1

  • Check the tables, sometimes the database is Utf-8, but the tables are not.

1 answer

6


Try applying the Character set directly to the DB call like this:

$db = new db("mysql:host=127.0.0.1;port=8889;dbname=mydb", charset=UTF8, "dbuser", "dbpasswd");
$db->exec("SET CHARACTER SET utf8");

or in the class constructor:

$options = array(
    PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
); 
public function __construct($dsn, $user="", $passwd="", $options) {
  //
}

Browser other questions tagged

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