Save Data in Arabic in MySQL database

前端 未结 7 1877
我在风中等你
我在风中等你 2020-11-22 14:13

I have changed the charset of the tables and of the column, i get the arabic text as ???? marks in MYSQL database

here is the design of the table

  C         


        
相关标签:
7条回答
  • 2020-11-22 14:50

    To read ,write and sort Arabic text in mysql database using php correctly, make sure that:

    1. MySQL charset: UTF-8 Unicode (utf8)

    2. MySQL connection collation: utf8_general_ci

    3. your database and table collations are set to: utf8_general_ci or utf8_unicode_ci

    Then, add this code in your php script when you connect to db:

    mysql_query("SET NAMES 'utf8'");
    mysql_query('SET CHARACTER SET utf8');
    

    For more details

    0 讨论(0)
  • 2020-11-22 14:52

    Change the database tables collations types to utf8_general_ci and also table fields collations change to utf8_general_ci.

    0 讨论(0)
  • 2020-11-22 14:59
    CREATE TABLE mydb.categories         
    (category_id tinyint(2) NOT NULL AUTO_INCREMENT
    ,category_name MEDIUMTEXT NOT NULL
    ,PRIMARY KEY (category_id)) DEFAULT CHARACTER SET utf8
    
    0 讨论(0)
  • 2020-11-22 15:03

    Try this code :

    $conn = new mysqli($server,$username,$password,$dbname);
    $conn->set_charset("UTF8");
    
    0 讨论(0)
  • 2020-11-22 15:06

    Make sure that your client software is also using UTF-8.

    http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

    0 讨论(0)
  • 2020-11-22 15:07

    To insert Arabic Data manually into your Phpmyadmin.

    First you check either your database , table and column name is utf8 set or not. If these are not set to utf8 then first you set it then you may insert arabic data into you db table.

    YOU MAY CHECK EACH OF THESE BY LOOKING BELOW EXAMPLE.

    For Database:

    SELECT default_character_set_name FROM information_schema.SCHEMATA S
    WHERE schema_name = "schemaname";
    

    For Tables:

    SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
           information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
    WHERE CCSA.collation_name = T.table_collation
      AND T.table_schema = "schemaname"
      AND T.table_name = "tablename";
    

    For Columns:

    SELECT character_set_name FROM information_schema.`COLUMNS` C
    WHERE table_schema = "schemaname"
      AND table_name = "tablename"
      AND column_name = "columnname";
    

    You may easily set utf8 to your tables if you are using SQLYog.

    Just right click on db, table, column name and click on alter option and set to

    Database Chartset = utf8 Database Collation = utf8_general_ci .

    Just Enjoy ....

    0 讨论(0)
提交回复
热议问题