-1

Since I was unable to find a solution over stack-overflow and on the net I am posting this question:

I have a php page that contains the following:

<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-8">
<META HTTP-EQUIV="Content-language" CONTENT="he">

and a php function that gets Hebrew chars and displays it on the above php page. The mySql DB is defined as utf-general-ci. Also the PDO connection is set as follow:

$conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8",   $username, $password);

The problem is that the php page displayed html Hebrew chars but regarding the DB Hebrew values - it displays them as question marks inside a triangle...

Any body got any idea what is wrong...? Thanks.

Eyal Sooliman
  • 1,876
  • 23
  • 29

1 Answers1

2

You are using the ISO-8859-8 charset to display the chars and utf8 to encode them in your database, you need to use one of them but not both (I recommand you unicode/utf-8).

EDIT : Also, be careful with your file encoding.

Aurel
  • 631
  • 3
  • 18
  • Thank, Should I only display the chars or only encode them? – Eyal Sooliman Apr 21 '16 at 10:41
  • I can see that the Hebrew values from DB are display correctly in the page, but the html Hebrew chars are not... only if I replace the meta tag to be: ISO-8859-8. So if I do that, then the Hebrew values from DB are showing "?????"... can't find the reason for that. – Eyal Sooliman Apr 21 '16 at 11:05
  • Check the encoding of your HTML file, it needs to be the same as your meta tag and DB encoding – Aurel Apr 21 '16 at 11:14
  • Yes I know but like I wrote above, When the meta tag is set to utf-8 I see the DB Hebrew values fine, but not the Hebrew chars in the page. When I switch the meta to ISO-8859-8, I get the opposite: DB values are "???" and Hebrew chars are from page are fine... – Eyal Sooliman Apr 21 '16 at 11:32
  • Switch everything to either ISO-8859-8 or UTF-8 and you'll be fine. – Aurel Apr 21 '16 at 11:34