I'm reading data from a Access database with PHP & ODBC driver to insert into MySQL. It works nicely, except with data containing accents.
I use the following to retrieve the data from a Access Table:
$conn = new \PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ={$dbPath}; Uid={$dbUser}; Pwd={$dbPass};");
$stmt = $conn->prepare('SELECT * FROM users');
$stmt->execute();
When looping through results I have a field named name
which holds the user name.
$name = $row['name'];
The output of this value into the screen shows:
Jo�o
The correct word is "João". When saving in the MySQL database it saves Jo?o.
If I output the value into the screen using the utf8_decode
works great, it shows João.
print_r(utf8_decode($name));
But when saving using the same function it saves once again Jo?o.
I have also tried to save the data using htmlspecialchars(utf8_decode($name), ENT_QUOTES, 'UTF-8')
but the value is saved as empty.
How do I insert into MySQL database the correct value "João"? My MySQL table has the collation utf8_bin
.