Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 742
  • Last Modified:

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?
0
itaym
Asked:
itaym
  • 4
2 Solutions
 
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

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now