I am trying to save Hindi characters in a MySQL database using PHP. When I do, this is what is saved into my database:
तीन से अधिक
When I search this on Google, Google is able to properly decode the characters that I want: तीन से अधिक. What am i doing wrong? I want the data to be stored in human-readable Hindi characters.
This is the query I'm using:
INSERT INTO testing (instruction) VALUES ('निम्नलिखित पांच मे से चार उपरोक्त व्यवस्था में अपनी स्थिति के आधार पर एक निश्चित प्रकार से एक समान हैं और एक समूह बनाते है। वह एक कौन सा है जो उस समूह से सम्बन्धित नही है?')
Check the encoding that your browser uses. Also check if the data is being stored in hindi in MySQL properly. If yes, the problem is with browser encoding.
I doubt it's possible. The problem is (so far as I can tell) that MySQL defaults to saving to HTML escape codes.
You could try using this in your query to avoid that:
CAST('यहाँ हिंदी पाठ' AS CHAR CHARACTER SET utf16)
This would be in place of just typing ' यहाँ हिंदी पाठ '.
However, I'm not near a MySQL server I could use to test at the moment and I have little to no experience with storing non-Latin alphabets, so this is pure guesswork. It could also be that MySQL just converts it anyway.
Apologies if the Hindi is wrong, I'm using Google Translate
This is problem of encoding. Try to set the Interclassement of your DB and table to utf8-general-ci
this works for me:
CREATE TABLE IF NOT EXISTS `testing` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`instruction` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
INSERT INTO `testing` (`id`, `instruction`) VALUES
(1, 'निम्नलिखित पांच मे से चार उपरोक्त व्यवस्था में अपनी स्थिति के आधार पर एक निश्चित प्रकार से एक समान हैं और एक समूह बनाते है। वह एक कौन सा है जो उस समूह से सम्बन्धित नही है?');
Result:
SELECT * FROM `testing` WHERE `instruction` LIKE '%व्यवस्था%'
+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id | instruction |
+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 1 | निम्नलिखित पांच मे से चार उपरोक्त व्यवस्था में अपनी स्थिति के आधार पर एक निश्चित प्रकार से एक समान हैं और एक समूह बनाते है। वह एक कौन सा है जो उस समूह से सम्बन्धित नही है? |
+----+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)