0

I have a table structure like this.

enter image description here

I want to insert values in examples column that can be either in Hindi or English. To insert values, I have added a procedure as follows:

 PROCEDURE `insertCategories`(parentCatID INT(11), categoryName VARCHAR(100), categoryType VARCHAR(100), examples VARCHAR(200))
 BEGIN
  DECLARE parentID INT(11) DEFAULT parentCatID; 
  DECLARE categoryTitle VARCHAR(100) DEFAULT categoryName;
  DECLARE catType VARCHAR(100) DEFAULT categoryType;
  DECLARE catExamples VARCHAR(200) DEFAULT examples;
  IF categoryTitle !='' AND catType!=''  THEN
    INSERT INTO categories(cat_title, parent_catID, `types`, examples) VALUE(categoryTitle, parentID, catType, catExamples);
  END IF;
END$$

I am trying to call this procedure using $executingProcedure = $mysqli->query("CALL insertCategories(0, 'Exporter', 'BC', 'निर्यातक')");

But it stores value like

 निर्यातक

I know this is charset problem which I tried to fix with the solution given on this link, but it didn't work. I am stuck at this problem and any help would be appreciated.

EDIT

I have tried it in mysql and it's working, but I need to do this using mysqli.

EDIT

Seems like problem was in html part. Added the following tag and everything worked fine.

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
Community
  • 1
  • 1
A J
  • 3,970
  • 14
  • 38
  • 53

2 Answers2

1

Use utf8_general_ci collation for example column in your table structure. And use following PHP statement in your PHP script.

 header('Content-type: text/html; charset=UTF-8');
A J
  • 3,970
  • 14
  • 38
  • 53
Sagar
  • 642
  • 3
  • 14
0

You need to add set charset to utf-8.

In short you need to add following line anywhere in <head> in both pages from you saving and where you showing. It will work doesn't matter, you saving mysqli or mysql.

 <meta charset="UTF-8">

It will work.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Hemant Maurya
  • 136
  • 1
  • 1
  • 14