Learning
Learning

Reputation: 20051

Mysql Collation for arabic using php

I am facing problem with mysql database. I cant save arabic text into the mysql data even i change the collation to cp1256_general_ci and tried other collation. I cant get much help from search.

Anyone who can help me out please help

I have change collation at database level as well as colum level to cp1256_general_ci for some fields.

Please suggestion how should i set this as i am NEW PHP and MySQL

I also write simple INSERT statement to insert input data in mysql do i have to take any case while inserting data into mysql if it is in arabic

Upvotes: 4

Views: 3146

Answers (1)

Pekka
Pekka

Reputation: 449823

The short answer is: Use UTF-8 everywhere. "Everywhere" means

  • In all forms that are used to store data in your database
  • The database connection
  • The database tables and columns
  • In all pages that output data from the database.

if you have existing CP-1256 data (or incoming data in that character set that you can't change) you can use iconv() to convert it into UTF-8.

Note that if using UTF-8, you need to make sure you use multibyte-safe string functions. This is often already the case because standard function like strlen() get mapped to mb_strlen(). To find out whether this is the case on your server, see the manual entry on the issue.

Upvotes: 6

Related Questions