This may seem like a dumb question, I've tried many different solutions with setting the charset but nothing helps. I've got a database with different texts for each day, some of them has got the letters åäö and when loading the page, åäö is just visible as question marks in a black rhombus.
It's working perfectly on my other page but I can't figure out what's wrong.
Here's my code.
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM xxxx WHERE xxx = 'xxxxx'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
'.$row["stackinfo"].'<br>
'.$row["monday"].'<br>
'.$row["tuesday"].'<br>
'.$row["wednesday"].'<br>
'.$row["thursday"].'<br>
'.$row["friday"].'
</body>
</html>
';
}
} else {
echo "0 results";
}
mysqli_close($conn);
Also, it would be useful if ü, ø, and æ worked as well.
The db uses latin1_swedish_ci
.
Thanks in advance!
Update, the full php but without the table name (just for security.)
<?php header('Content-Type: text/html; charset=utf-8');
define('INCLUDE_CHECK',true);
require 'connection file';
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_database);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM xxx WHERE ClassID = 'xxx'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="card">
'.$row["stackinfo"].'<br>
'.$row["monday"].'<br>
'.$row["tuesday"].'<br>
'.$row["wednesday"].'<br>
'.$row["thursday"].'<br>
'.$row["friday"].'
</div>
</body>
</html>
';
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>