Hebrew and MySQL

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?
LVL 1
itaymAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ajaikumarrCommented:
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
ellandrdCommented:
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
ellandrdCommented:
any luck?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.