i'm trying to insert accented char into mysql table with encoding utf8_general_ci
.
This is a simple string that i'm trying to insert:
Porto leça da palmeira
To insert that string i'm using php in this way:
$string = "Porto leça da palmeira";
$id = "xxxx";
$sql = "INSERT INTO city_translates (id,city) VALUES ('$id','$string')";
$dbh = new PDO("mysql:host.....");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->query($sql);
When i try when to access from MysqlWorkBench
that string, it has been stored in this way:
Porto - Le?Ãa da Palmeira
if i try to use utf8_encode
such as:
$string = utf8_encode($string);
it will be stored in this way:
Porto - Le?ßa da Palmeira
How can i solve? What could be my error?
Thanks!