1

This is my connection script now I want to set Mysqli charset utf8 to show Hindi character where I have to set this?

public function __construct()
{
    $this->conn=new mysqli($this->host,$this->username,$this->pass,$this-
    >db_name);

    if($this->conn->connect_errno)
    {
        die ("database connection failed".$this->conn->connect_errno);
    }
}
Qirel
  • 25,449
  • 7
  • 45
  • 62
  • 1
    All it takes, is one wrong charset setting in your application - *everything* needs to be the same charset! I have previously written [**an answer about UTF-8 encoding**](https://stackoverflow.com/a/31899827/4535200) that contains a little checklist, that will cover *most* of the charset issues in a PHP/MySQL application. There's also a more in-depth topic, [**UTF-8 All the Way Through**](https://stackoverflow.com/q/279170/4535200). Most likely, you'll find a solution in either one or both of these topics. – Qirel Sep 26 '17 at 19:34
  • 2
    Possible duplicate of [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Qirel Sep 26 '17 at 19:34
  • I set utf8 in database and on its table on mysql. also declared in php header, the actual issue is when I am declaring $conn>set_charset("utf8"); its showing error like Call to a member function set_charset() on null on excutign application. So where I can declare utf8 charset on php file. – Design Work Sep 27 '17 at 07:26
  • You need to understand what's being said in the linked answers. `$conn` is a mysqli connection object. You use a class to define the connection, so it should be `$this->conn` instead of `$conn`, directly after opening the connection. To set the PHP header and file encoding, look at the other bullet points in the topic. – Qirel Sep 27 '17 at 10:06

0 Answers0