Unicode data retrieve from mysql using php problem

I want to retrieve unicode based (Bengali language) data from mysql (wamp server 3 is running). I have inserted data using PhpMyAdmin and can read the font. but when I tried to read using php in html it just shows ‘???’ ! I know it is creating problem with unicode data. any solution?? how I can handle in PHP when I can read data from PhpMyAdmin ?

my code is: for lastest row only
[php]

<?php $connect = mysqli_connect("localhost", "root", "", "sumonn"); $sql=("SELECT * FROM `notice` ORDER BY id DESC limit 1" ); $result_set=mysqli_query($connect,$sql); while($row=mysqli_fetch_array($result_set)) { echo $row['notice']; } ?>

[/php]

“mysqli::set_charset()” link solved my problem. I added my code and looks like bellow
[php]

<?php $connect = mysqli_connect("localhost", "root", "", "sumonn"); // this lines solved my problme, changing latin1 to utf8 after connction (start) if (!mysqli_set_charset($connect, "utf8")) { printf("Error loading character set utf8: %s\n", mysqli_error($connect)); exit(); } else { printf("Current character set: %s\n", mysqli_character_set_name($connect)); } // this was the last line of my changed code $sql=("SELECT * FROM `notice` ORDER BY id DESC limit 1" ); $result_set=mysqli_query($connect,$sql); while($row=mysqli_fetch_array($result_set)) { echo $row['notice']; } ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service