0

I want to build my website in Hebrew lang.

When I write

<meta charset="utf-8">

in the title the labels are looks good but the letters from the DB are all question mark - "????"

When I write

<meta charset="windows-1255">

letters from DB are OK but all labels are "???".

BTW - I'm also use this code after connecting to the DB:

mysql_query("SET NAMES 'hebrew'");

setlocale(LC_ALL, 'he');

how can I fix that?

Roi
  • 1
  • 1

1 Answers1

0

You must tell your DB connection to work in UTF-8, try:

mysql_query( 'SET NAMES utf8' );

Do this right after you create your MySQL connection. And keep your pages in UTF-8.

Also if you are starting a new project, you really should use the mysqli_* functions instead of mysql_*

Sébastien
  • 11,860
  • 11
  • 58
  • 78
  • should I use "mysqli_" all the time? for instance - "$query = mysqli_query("SELECT * FROM `users_setup` WHERE (`userID` = '$userID')");" ? – Roi Sep 28 '13 at 13:41
  • Be aware that you cannot simply replace mysql_ in your code with mysqli_. Fix your code first and then read this: http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php/14112684#14112684 – Sébastien Sep 28 '13 at 13:44