I have alot of data in urdu and I want to store in in database using php script. Someone please help me. I have tried all these things , mysqli_set_charset($link,"utf8"); and also change the collation to utf8_general_ci but its not working.
Asked
Active
Viewed 841 times
-1
-
Possible duplicate of [UTF-8 all the way through](http://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – user3942918 Mar 03 '17 at 07:34
-
My question is different!! – Ashna Ali Mar 03 '17 at 07:37
-
1@AshnaAli your question could be duplicate so provide some code example this can help resolving your issue – Abdul Rafay Mar 03 '17 at 07:42
1 Answers
1
It's not clear to me from your question where your problem lies: is it that your MYSQL tables are not in UTF8, or is it that your Urdu data is not in UTF8?
To create a MYSQL table in UTF8, use a CREATE statement such as:
CREATE TABLE tableName (
col1 INT,
(etc.)
) DEFAULT CHARSET utf8;
To alter an existing table, use an UPDATE command such as
ALTER TABLE tab CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
see also this answer: How to change all the tables in my database to UTF8 character set?
Or, for more ways of changing the MYSQL encoding using PHP functions, see this answer: Error in insertion urdu data in php Mysql
To convert PHP strings to UTF8 if you don't know your encoding, see this answer: PHP: Convert any string to UTF-8 without knowing the original character set, or at least try