Add arabic support to mysql databases to use with php.

To add arabic support to mysql change the character set of client, connection, database, results and system to the utf8 and the collation_connection and collation_database to utf8_general_ci to check these from mysql client select the database and run this command:

mysql> SHOW VARIABLES LIKE 'c%';
Now to change the character sets to utf8 run these commands;
mysql> SET NAMES 'utf8';
mysql> ALTER DATABASE db_name CHARACTER SET utf8 COLLATE utf8_general_ci;
To change only table character set run this command:
mysql> ALTER TABLE table_name CONVERT TO CHARACTER SET utf8;
To check the database or single table character set run one of this commands:
mysql> SELECT default_character_set_name FROM information_schema.SCHEMATA S WHERE schema_name = "db_name";
mydql> 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 = "db_name" AND T.table_name = "table_name";
To insert the data with php add these to the php code to support utf8:
header('Content-Type: text/html; charset=utf-8');
mb_internal_encoding("UTF-8");
mb_http_output( "UTF-8" );
Add this to the html pages:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Add this to the form tag:
<form action="test.php" method="post" accept-charset="utf-8">
Also add the all the above codes for php query or other php codes and all form tages for arabic support.


<< Previous Next >>