MySQL DB language problem
Moderator: General Moderators
-
The-Master
- Forum Commoner
- Posts: 45
- Joined: Sun Aug 07, 2005 9:51 am
- Location: Israel
MySQL DB language problem
hi, i am running a mysql db on my apache and when i try to write a hebrew word or sentence and i view the record i wrote nothing is wrong but when i display the record on my site it writes "???? ??? - ????..." what charset should i use if i already tried the "hebrew_bin" and the "hebrew_general_ci"( the only charsets that are in hebrew)?
-
The-Master
- Forum Commoner
- Posts: 45
- Joined: Sun Aug 07, 2005 9:51 am
- Location: Israel
-
The-Master
- Forum Commoner
- Posts: 45
- Joined: Sun Aug 07, 2005 9:51 am
- Location: Israel
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
I could be wrong but I think Hebrew is one of the character sets that will require mbstring support to be compiled for PHP. If it isn't then you will have problems storing and processing hebrew text. Create a small php program with this in it...
Execute it on your server and scroll down the list and check for the mbstring module. If it isn't in there that may be part of the problem.
Code: Select all
<?php
echo phpinfo();
?>- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Not true...Oren wrote:You are all wrong... noting special need to be done, no special type of table no nothing.
PHP isn't your problem nor mysql. It is the browser encoding that's all, play with it a little bit
Because if you read what he is saying he can WRITE the Hebrew test without a problem so his browser does support the encoding. It is after the server gets the hebrew text that it is being messed up. The problem is either with the PHP or Mysql side. The problem it seems for him is determining which is the problem.
No, you got me wrong... I didn't say his broswer doesn't support it! What I said is that he needs to go to: View->Character Encoding (assuming he uses Firefox) and play with the available encoding sets there till he sees hebrew.
Just to make sure, I'll do a quick check and then post the result here in few minutes...
Edit:
Here is the result:
I used a normal table which I use when working with english (I never work with Hebrew only english to be honest), I just typed my name in hebrew in a form and then PHP inserted the result into my database, then I pulled the info from the database and displayed it in my browser (Firefox). The result was this: I saw exactly what I typed into the form (in Hebrew).
Just to make sure, I'll do a quick check and then post the result here in few minutes...
Edit:
Here is the result:
I used a normal table which I use when working with english (I never work with Hebrew only english to be honest), I just typed my name in hebrew in a form and then PHP inserted the result into my database, then I pulled the info from the database and displayed it in my browser (Firefox). The result was this: I saw exactly what I typed into the form (in Hebrew).
-
The-Master
- Forum Commoner
- Posts: 45
- Joined: Sun Aug 07, 2005 9:51 am
- Location: Israel
The browser encoding is fine, i wrote some hebrew stuff in HTML and it worked just fine, i am working with "XAMPP" not the common Apache, ("XAMPP" is apache with php and some other mods built-in as you install the program).
the php info showed:
by the way i tried both firefox and IE and both have the same prob it definetly in the DB, when i view the records in the DB(with the same browser i use to view the php site) they are written in HEBREW so there is no browser prob...
when i pull out hebrew data i get "???? ???"...
one thing i have to say... i had less problems with apache on linux...
the php info showed:
Code: Select all
HTTP_ACCEPT_CHARSET : windows-1255,utf-8; (windows-1255 is hebrew encoding)when i pull out hebrew data i get "???? ???"...
one thing i have to say... i had less problems with apache on linux...
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
Try this
Try the following steps while configuring mysql :
1. If you are using MySQL 4.1 or higher, edit the my.cnf and add utf8 instead of latin1.
2. You must also specifiy the character set for table and also to table column as well.
3. Use the collation as utf8 in order to sort the records.
If you want default character set as utf8, use DEFAULT CHARSET=utf8 and want default collation as utf8, use DEFAULT COLLATE=utf8_general_ci .
4. In php script from where you want to display the unicode strings, add the following line in top of the script .
5. Finally, execute the following query to set the character set as utf8.
That's it!
Cheers,
Dibyendra
1. If you are using MySQL 4.1 or higher, edit the my.cnf and add utf8 instead of latin1.
2. You must also specifiy the character set for table and also to table column as well.
3. Use the collation as utf8 in order to sort the records.
Code: Select all
CREATE TABLE `tbl_test` (
`id` int(11) NOT NULL auto_increment,
`full_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT ;4. In php script from where you want to display the unicode strings, add the following line in top of the script .
Code: Select all
header('Content-Type: text/html; charset=utf-8');Code: Select all
mysql_query( "SET NAMES 'utf8'");Cheers,
Dibyendra