Nika Gogiashvili
Nika Gogiashvili

Reputation: 1

php data insert into mysql utf8 not working

I have 3 php files and 1 sql file. When I insert data in MYSQL on my language it works but, when I go in ADMINPHP and check base it shows me similar ნიკა symbols. What can I do for this problem? THIS IS MY FILE LINK

Upvotes: 0

Views: 1341

Answers (3)

Ariful hasan
Ariful hasan

Reputation: 323

Modify table field using

ALTER TABLE <tab_name> MODIFY <field_name> DATA_TYPE NOT NULL  COLLATE utf8_unicode_ci ;

When saving file using php, use this line of code before run query

mysqli_set_charset($con,"utf8");

Upvotes: 0

sg-
sg-

Reputation: 2176

Something is not set to UTF-8.

  1. Check the database settings. Make sure everything is UTF-8. Run these commands in your database using the MySQL command line, MySQL Workbench, PHP MyAdmin, or any other database client:

    -- Check the charset of the database SHOW VARIABLES LIKE 'char%';

    -- Check the collation of the database SHOW VARIABLES LIKE 'coll%';

    -- Check the charset of the schema SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "schema_name";

    -- Check the charset of each table 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 = "schema_name" AND T.table_name = "table_name";

    -- Check the charset of each column SELECT character_set_name FROM information_schema.COLUMNS C WHERE table_schema = "schema_name" AND table_name = "table_name" AND column_name = "column_name";

  2. Make sure the content type of your html document is UTF-8. You can check this in the Firebug console. You can also add code like the following to your webpage to set it:

<?php header('Content-Type: text/html; charset=utf-8'); ?>

  1. Check the character set of the client you are using (MySql Workbench etc). If you are using PHPMyAdmin, make sure the following settings exist in config.inc.php:

    $cfg['DefaultLang'] = 'en-utf-8'; $cfg['DefaultCharset'] = 'utf_8'; $cfg['DefaultConnectionCollation'] = 'utf8_general_ci'; $cfg['Lang'] = 'en-utf-8';

Upvotes: 0

talsibony
talsibony

Reputation: 8746

make sure all fields you entering the data into are set to utf-8, and run the following query after selecting the db

SET NAMES utf8

Upvotes: 1

Related Questions