I'm encountering what I'm sure is an encoding error but I can't seem to find the weak link in my logic. In particular, when trying to insert a Greek lambda into my database, the cell is blank after the lambda.
The process:
Before any html is printed, I'm doing:
header('Content-Type: text/html; charset=utf-8');
Next, I'm connecting using PDO:
$dsn = 'mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'] . ';charset=utf8';
$options = array(
PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
try {
$dbh = new PDO($dsn, $config['username'], $config['password'], $options);
$dbh->exec("SET NAMES utf8");
$dbh->exec("SET FOREIGN_KEY_CHECKS = 1");
When I do
SHOW FULL COLUMNS FROM my_table
I can see that the collation is utf8_general_ci. When I do:
echo mb_detect_encoding($data_to_be_entered);
I get UTF-8
When I echo out $data_to_be_entered into the console right before I insert it into the database, I see: (=23)
However, in my database, I just see ( as the entry.