-1

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.

Ashna Ali
  • 33
  • 1
  • 6

1 Answers1

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

Community
  • 1
  • 1
ATJ
  • 309
  • 2
  • 10