ImHigh
ImHigh

Reputation: 191

Insert Hebrew text to SQL databse table ( Codeigniter)

I have set my database collation to : Hebrew_CI_AS

Also i have added this code on the head section of view pages

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

Please let me the possible solution for it.

Upvotes: 0

Views: 195

Answers (2)

Alaa M. Jaddou
Alaa M. Jaddou

Reputation: 1189

While working on this mini-project I’ve realized that there is hardly any online tutorials on using the Hebrew font. Here’s my solution which is fairly simple and works effectively.

  • Set the HTML page charset encoding to utf8:
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8“>
  • set the ‘collation’ attribute for the fields which are to accept hebrew text to: utf8_bin

  • within your php script, right before calling the mysql_query function to insert the data into your DB, use both the utf8_encode function along with addslashes. This will encode the data into utf8 friendly characters.

  • when pulling the text from the DB onto the page, make sure to use the utf8_decode along with stripslashes in order to display the data on the page.

as @Perrykipkerrie says. this is a good tutorial.

Upvotes: 0

Daniel_ZA
Daniel_ZA

Reputation: 574

If your database collation is utf8_general_ci (this is what I normally use) it should display correctly in the table.

In addition to the code you have in the head section, I have also used the HTML lang attribute for specific HTML elements in past projects:

<p lang='he'> Some Hebrew text. </p>

Upvotes: 1

Related Questions