Web Analytics Made Easy -
StatCounter Unicode data retrieve from mysql using php problem - CodingForum

Announcement

Collapse
No announcement yet.

Unicode data retrieve from mysql using php problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 Code:
    <?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'];
        }

    ?>
    Last edited by vinyl-junkie; Sep 11, 2016, 12:46 PM. Reason: added code tags

  • #2
    "mysqli::set_charset()" link solved my problem. I added my code and looks like bellow

    <?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'];
    }

    ?>

    Comment

    Working...
    X