Chetan Ghadiya
Chetan Ghadiya

Reputation: 368

gujarati fonts not display properly from mysql database

we are using this code but Gujarati fonts not display properly on browser ... my sq l about field have this text "ફૂટપાથ વગરના રોડ ઉપર રાહદારીએ શું કરવું?"

<?


        $query = MySQL_query($con,"SELECT * FROM guj1") or die(mysqli_error());
        if(MySQL_nun_rows($query)){
            while($row=MySQL_fetch_assoc($query)){
                echo utf8_decode($row['about']);    
            }
        }
        MySQL_close($con); 

?>

Upvotes: 3

Views: 4329

Answers (3)

Class
Class

Reputation: 3160

Probably not setting the Connection Character Sets and Collations correctly which can be done with the following

mysql_query("SET NAMES 'utf8'");

Upvotes: 2

Mujtaba Haider
Mujtaba Haider

Reputation: 1650

Include utf-8 header at start of your file

header("Content-Type: text/html; charset=utf-8");

Upvotes: 1

Add this on top of your PHP code !

header('Content-Type: text/html;charset=utf-8');

In your code like..

<?php
header('Content-Type: text/html;charset=utf-8'); //<=---- Add here


        $query = MySQL_query($con,"SELECT * FROM guj1") or die(mysqli_error());
        if(MySQL_nun_rows($query)){
            while($row=MySQL_fetch_assoc($query)){
                echo utf8_decode($row['about']);    
            }
        }
        MySQL_close($con); 

?>

Upvotes: 2

Related Questions