Consider a table with three columns id,name and bgname where bgname is a cyrillic equivalent of name.The table is created with UTF-8 collation. After using the following:
<?php
$sql = 'SELECT bgname FROM categories';
function getZapisi($sql,$dbh) {
foreach ($dbh->query($sql) as $row) {
print $row['bgname'] . "<br/>";
}
}
try {
$dbh = new PDO("mysql:host=localhost;dbname=test", 'root', 'pass');
/*** echo a message saying we have connected ***/
getZapisi($sql,$dbh);
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>
I get ??? from the query no matter if I use cp1251 or utf-8 collation for the bgname column. Thanks in advance