jones
jones

Reputation: 755

Inserting and selecting Arabic using codeigniter

I am trying to insert Arabic text into db using a CodeIngiter model.

My Table field name and type is as follows:

product_name_arab    text    utf8_general_ci

Insertion works perfectly; it's inserted as Arabic. The issue is with displaying it back on the view page... The data shows as:

??????????? ?????????? - ?????? ???????????..

I checked the Config file character set and the database character set they are UTF-8

And in View I added

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

But still the issue persists.

Am I missing something?

Upvotes: 0

Views: 1493

Answers (1)

Alexey
Alexey

Reputation: 3637

Things to test:

  1. Before storing values in the DB, check what you are actually storing. Before calling DB, do a check on what data you are about to send.
  2. Codeigniter has a nice function $this->db->last_query(); Echo it somewhere and see the output. This will show what CodeIgniter sends to DB.

If both of those steps are fine, then it is a DB issue.

What you can do is change the basic encoding of the DB from UTF-8 to your local (not really sure which one would show arabic correctly. When I work with russian DBs I chose cyrillic-1251-general. That handles all Russian characters). I am using phpMyAdmin, and it provides amazing functionality for mysql language issues.

Upvotes: 4

Related Questions