?
Solved

Hebrew and MySQL

Posted on 2005-04-03
7
Medium Priority
?
728 Views
Last Modified: 2008-01-09
Problem:
=======

Hebrew Characters stored in MySQL are not displayed correctly. Instead, if I browse the database (using PHP code I wrote  and apache) I get question marks ('??????') instead of the Hebrew characters
I tried to troubleshoot the problem by avoiding using mySQL to see if the problem might be in the Apache server not configured correctly for Hebrew charaters. The result was OK – Apache displayed Hebrew charactes correctly.
That leaves mySQL as the one causing the problems.
 

Environment:
==========

1. I installed on Windows 2000 Server +  PHP 5.0.4,  Apache 1.3.33,  MySQL 4.1.10a,  PHPmyadmin 2.6.1-pl3 ; These are all bundled in the WAMPSERVER package
2. I created new db on charset 'utf8_unicode_ci', with data on English and hebrew (different rows).
3. I created the following php file
4. The Hebrew data from dBase is giving me question marks (????? - instead of hebrew characters).  

I added as following to mywamp.ini:
[mysqld]
default-character-set=utf8
default-collation=utf8_unicode_ci
init-connect="SET NAMES utf8"
 
[wampmysqld]
default-character-set=utf8
default-collation=utf8_unicode_ci
init-connect="SET NAMES utf8"

I check that I have on apache\conf\httpd.conf :
AddLanguage he .he
LanguagePriority with he
AddCharset WINDOWS-1255  .cp-1255
and even: AddDefaultCharset WINDOWS-1255

All these didn't work for me.

The code I'm using:
==============

<HTML>
<head>
<meta http-equiv="content-type" content="text-html; charset=utf-8">
</head>
<?php
 $mysql_link=mysql_connect('localhost','','') or die("ERROR: cannot connect to MySQL server.<br>");
  echo "connected successfully to MySQL server.<br>";
 if (mysql_select_db('yed')){ echo "DB selected.<br>";}
  else{     echo "Could not select the DB.<br>";}
$result=mysql_query("SELECT * FROM test1",$mysql_link);
if ($result){echo "test<br>";}
else{echo "wrong<br>".$result."<br>".$mysql_link;}
mysql_close($mysql_link);
?>
<body style="font-family: Arial, Helvetica, sans-serif;">
<TABLE border=1 cellpadding=2 cellspacing=2>
   <?
     //printing all the rows of the table:
     while ($grade_row=mysql_fetch_array($result))
     {
        echo "<TR>";
        echo "<TD align=\"right\"><B>".$grade_row["id"]."</B></TD>";
        echo "<TD align=\"right\"><B>".$grade_row["name"]."</B></TD>";
        echo "</TR>";
        echo "<TR>";
        echo "<TD align=\"right\"><B>&#1506;&#1497;&#1489;&#1512;&#1497;&#1514;</B></TD>";
        echo "<TD align=\"right\"><B>&#1504;&#1497;&#1505;&#1497;&#1493;&#1503;</B></TD>";
        echo "</TR>";
     }
   ?>
</TABLE>
</body>
</html>

================
What else should I check in MySQL to make Hebrew display correctly?
0
Comment
Question by:itaym
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
7 Comments
 
LVL 16

Accepted Solution

by:
ellandrd earned 500 total points
ID: 13692324
0
 
LVL 11

Assisted Solution

by:ajaikumarr
ajaikumarr earned 500 total points
ID: 13694674
Hai,
      Read some where that have to specificy the charset inside the pages... So just add either the following line on HTML page

      <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=iso-8859-8-i">

or this lines inside php page
      header("Content-Type: text/html; charset=iso-8859-8-i")


Charset 8859-8 is for Hebrew language
      http://dev.mysql.com/doc/mysql/en/charset-se-me-sets.html

Bye
Ajai
0
 
LVL 16

Expert Comment

by:ellandrd
ID: 13719533
try this:

<HTML>
<head>
<meta http-equiv="content-type" content="text-html; charset=iso-8859-8-i">
</head>
<?php
 $mysql_link=mysql_connect('localhost','','') or die("ERROR: cannot connect to MySQL server.<br>");
  echo "connected successfully to MySQL server.<br>";
 if (mysql_select_db('yed')){ echo "DB selected.<br>";}
  else{     echo "Could not select the DB.<br>";}
$result=mysql_query("SELECT * FROM test1",$mysql_link);
if ($result){echo "test<br>";}
else{echo "wrong<br>".$result."<br>".$mysql_link;}
mysql_close($mysql_link);
?>
<body style="font-family: Arial, Helvetica, sans-serif;">
<TABLE border=1 cellpadding=2 cellspacing=2>
   <?
     //printing all the rows of the table:
     while ($grade_row=mysql_fetch_array($result))
     {
        echo "<TR>";
        echo "<TD align=\"right\"><B>".$grade_row["id"]."</B></TD>";
        echo "<TD align=\"right\"><B>".$grade_row["name"]."</B></TD>";
        echo "</TR>";
        echo "<TR>";
        echo "<TD align=\"right\"><B>&#1506;&#1497;&#1489;&#1512;&#1497;&#1514;</B></TD>";
        echo "<TD align=\"right\"><B>&#1504;&#1497;&#1505;&#1497;&#1493;&#1503;</B></TD>";
        echo "</TR>";
     }
   ?>
</TABLE>
</body>
</html>

Ellandrd
0
 
LVL 16

Expert Comment

by:ellandrd
ID: 13737481
any luck?
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating and Managing Databases with phpMyAdmin in cPanel.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question