I am using the following code to output results from my MySQL database table in a PHP foreach() loop. However, the characters stored in the database are Cyrillic and there are being displayed as question marks "??????" in the database table. $translated is the string variable that should display Cyrillic characters in the Ukrainian language but are just showing as question marks. Please let me know
<?php
/*** mysql hostname ***/
$hostname = 'localhost';
/*** mysql username ***/
$username = 'testname';
/*** mysql password ***/
$password = 'pass234';
try {
$dbh = new PDO("mysql:host=$hostname;dbname=testdatabase", $username, $password);
/*** echo a message saying we have connected ***/
/* echo 'Connected to database'; */
}
catch(PDOException $e)
{
echo $e->getMessage();
exit();
}
?>
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="UTF-8">
<title>MLC Translate Tool</title>
<!--IE Compatibility modes-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--Mobile first-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="img/logo1.ico"/>
<!-- global styles-->
<link rel="stylesheet" href="css/components.css"/>
<link rel="stylesheet" href="css/custom.css"/>
<!--end of global styles-->
<!--plugin styles-->
<link rel="stylesheet" href="vendors/select2/css/select2.min.css" />
<link rel="stylesheet" href="vendors/datatables/css/scroller.bootstrap.min.css" />
<link rel="stylesheet" href="vendors/datatables/css/colReorder.bootstrap.min.css" />
<link rel="stylesheet" href="vendors/datatables/css/dataTables.bootstrap.min.css" />
<link rel="stylesheet" href="css/pages/dataTables.bootstrap.css" />
<link rel="stylesheet" href="css/plugincss/responsive.dataTables.min.css" />
<!-- end of plugin styles -->
<!--Page level styles-->
<link rel="stylesheet" href="css/pages/tables.css" />
<link rel="stylesheet" href="#" id="skin_change" />
<!--End of page level styles-->
</head>
<body class="datatable_page">
<table class="table table-striped table-bordered table-hover " id="sample_6">
<thead>
<tr>
<th>Original</th>
<th>Translated</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM wp_trp_dictionary_en_us_uk;";
foreach ($dbh->query($sql) as $row)
{
$original = $row['original'];
$translated = $row['translated'];
echo "<tr>";
echo "<td>$original</td>";
echo "<td>$translated</td>";
echo "<td></td>";
echo "<td></td>";
echo "</tr>";
}
?>
</tbody>
</table>
<script src="js/components.js"></script>
<script src="js/custom.js"></script>
<!--end of global scripts-->
<!--plugin scripts-->
<script src="vendors/select2/js/select2.js"></script>
<script src="vendors/datatables/js/jquery.dataTables.min.js"></script>
<script src="js/pluginjs/dataTables.tableTools.js"></script>
<script src="vendors/datatables/js/dataTables.colReorder.js"></script>
<script src="vendors/datatables/js/dataTables.bootstrap.min.js"></script>
<script src="vendors/datatables/js/dataTables.buttons.min.js"></script>
<script src="js/pluginjs/jquery.dataTables.min.js"></script>
<script src="vendors/datatables/js/dataTables.responsive.min.js"></script>
<script src="vendors/datatables/js/dataTables.rowReorder.min.js"></script>
<script src="vendors/datatables/js/buttons.colVis.min.js"></script>
<script src="vendors/datatables/js/buttons.html5.min.js"></script>
<script src="vendors/datatables/js/buttons.bootstrap.min.js"></script>
<script src="vendors/datatables/js/buttons.print.min.js"></script>
<script src="vendors/datatables/js/dataTables.scroller.min.js"></script>
<!-- end of plugin scripts -->
<!--Page level scripts-->
<script src="js/pages/datatable.js"></script>
</body>
</html>