Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert Arabic data into mysql database

Tags:

php

mysql

mysqli

i tried entering Arabic text and insert it into mysql database using php, when print the row, all rows that in arabic looks like :

???? ???? ???? ????? ابو نصير عمان الاردن الاردن بببببببببببببببببب

i set my database to: Character set: utf8 -- UTF-8 Unicode Collation: utf8_general_ci

and every field in database: Character set: utf8 Collation: utf8_general_ci

i need to solve this problem and i appreciate all answers ..

like image 424
Mohammed F. Ghazo Avatar asked May 15 '13 21:05

Mohammed F. Ghazo


People also ask

How to add Arabic to MySQL?

To save an Arabic text into your MySql database table, you first check the table column is set to "utf8" or not. If not, switch to table structure tab of phpmyadmin and click change under action column, here you will see a column "Collation" and choose "utf8_general_ci" from utf8 group and save.

How do I insert an Arabic character into an SQL database?

For the field to be able to store unicode characters, you have to use the type nvarchar (or other similar like ntext , nchar ). To insert the unicode characters in the database you have to send the text as unicode by using a parameter type like nvarchar / SqlDbType. NVarChar .

Does MySQL support Arabic?

The MySQL database should just support Arabic letters. Especially if you tested this on your own computer with the same charsets and stuff, it should just work. phpMyAdmin on the other hand does have trouble with unicode characters.


1 Answers

Do the following:

  1. Include the following query in every page of your application mysql_query("SET NAMES 'utf8'");

  2. Be assured that your web pages are utf-8 encoded by the following meta tag:

like image 52
SaidbakR Avatar answered Sep 21 '22 20:09

SaidbakR