We recently moved from IIS 7.5 with PHP 5.3.4 to IIS 8 with PHP 5.5. We are having an issues with data pulled from MySQL. The issue was not present on the previous infrastructure.
When a string is pulled from MySQL and displayed to the client the encoding is not displaying properly.
Ex:
Text should display as and does on old infrastructure:
"¿Qué planearon Sandra y Carlos en este episodio?
But it displays as:
"¿Qué planearon Sandra y Carlos en este episodio?"php
I have tried the following:
Add header to client interprets all as UTF-8, no change.
header('content-type: text/html; charset=utf-8');
echo the encoded characters below: (they display correctly to client as: ä ö ü ß €.)
"\xc3\xa4"."\xc3\xb6"."\xc3\xbc"."\xc3\x9f"."\xe2\x82\xac";
Add encoding options to html_entity_decode for UTF-8. No Change.
Any ideas? Code blow.
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
// CONNECT TO THE DATABASE
$DB_NAME = 'removed';
$DB_HOST = 'removed';
$DB_USER = 'removed';
$DB_PASS = 'removed';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
// A QUICK QUERY ON A FAKE USER TABLE
$query = "SELECT * FROM `tablename` WHERE `item`='1234'";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
// GOING THROUGH THE DATA
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo html_entity_decode($row['prompt']);
}
}
else {
echo 'NO RESULTS';
}
// CLOSE CONNECTION
mysqli_close($mysqli);