I'm having troubles with accents on the character i (ï/î) to be put into a MySQL database using PHP. I've 2 names, Myîa and Myïa, and after the inserts I only have Myïa in my database.
The collation of the table is set to utf8_unicode_ci and the field itself is also utf8_unicode_ci. I've checked the DEFAULT_CHARACTER_SET_NAME
in the SCHEMATA table
which is set to utf8 for the database
.
database.php:
$dbs_cnt = mysqli_connect($dbs_hst, $dbs_usr, $dbs_psw, $dbs_nme);
if (!$dbs_cnt) { die(mysqli_connect_error()); }
if (!mysqli_set_charset($dbs_cnt, "utf8")) { echo mysqli_error($dbs_cnt); }
script.php
header('Content-Type: text/html; charset=utf-8');
include 'database.php';
// irrelevant code
$SQL = "
INSERT INTO " . $dbs_tbl . " (`Character`)
VALUES ('" . $CHR_NME . "')
";
if (!mysqli_query($dbs_cnt, $SQL)) { echo mysqli_error($dbs_cnt); }
Everything seemed to be working fine until I came across these names recently.
When trying to manually enter them in the database when one record is already present, I am getting the following errors:
#1062 - Duplicate entry 'Myîa' for key 'PRIMARY'
#1062 - Duplicate entry 'Myïa' for key 'PRIMARY'
I've been playing around with the collation (as it was latin1_swedish_ci), but that doesn't seem to help. After checking similar problems I've added the header aswell, but with no result either.
What am I missing?