Ile Popivanov Ile Popivanov - 7 months ago 19
SQL Question

Stuck again with loading UTF-8 Chars

LOL I am stuck again with this utf-8 loading. Last time someone told me when you load utf-8 add this

mysql_query('SET NAMES utf8');
but this time its not working. This is the code and some photos:

<?php } else {?>
<form action = "" method = "post">
<div class = "tablatekst">
<?php
$korisniklog = mysql_fetch_array(mysql_query("SELECT * FROM `korisnici` WHERE `Ime` = '$klogiran'"));
if($korisniklog == '0')
{
$logiran = false;
header("Location: index.php");
}
mysql_query('SET NAMES utf8');
$imeprezimelog = $korisniklog['ImePrezime'];
?>
Добредојдовте назад <?php echo $imeprezimelog; ?>
<center><input type="submit" name="odjava" value="Одјави се" class = "loginboxovi"/></center>
</div>
</form>

<?php } ?>


This is the row in mysql: http://prntscr.com/b1buxq
And this is how it shows on web: http://prntscr.com/b1bv4h

Answer

You are calling it in the inverted order:

mysql_query('SET NAMES utf8');

needs to be before your query, other ways you get the characters back in the default encoding.