html - UTF8 combination PHP/MySql -


this question has answer here:

my sql database have utf8_unicode_ci collation , html have utf8 (meta charset="utf-8").

when write in php:

$query = "select *  `subjects`  `year` = '$year'"; $result = $mysqli->query($query);  while($row = mysqli_fetch_array($result)){     echo "<option value='" .  $row['name'] . "'>" . $row['name'] . "</option>"; } 

instead čćšđ getting crazy values like: ?�...

add

mysql_query("set names 'utf8'"); mysql_query("set character set 'utf8_general_ci'"); 

before

$query = "select *  `subjects`  `year` = '$year'"; 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -