MySQL, Tutorials

Fetch hindi fonts from database in php

27 February 2019

Now I want to fetch all data from table and display on my php page, but when I’m trying to fetch data in my php code I’m getting text into the following format.

Post_title= ????/??????????/????/?????/?????/363/1
Post_title= ????/??????????/??????/??????/??????????/644/1
Post_title= ????/??????????/??????/??????/??????????/464/1

We need to use “set_charset” UTF-8 when database connection is established

    // Database configuration
    $dbHost = "localhost";
    $dbUsername = "root";
    $dbPassword = "xxxxxxxxxxxxx";
    $dbName = "test_db";

    // Create database connection
    $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);
    mysqli_set_charset( $db, 'utf8');
    // Check connection
    if ($db->connect_error) {
        die("Connection failed: " . $db->connect_error);

Leave a Comments