943,699 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 5188
  • MySQL RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 18th, 2008
0

Problem with Greek characters

Expand Post »
Hi all,

I have a problem with my php and mysql project.
I use an auctions software, named phpauction for my project.

I import into my database with utf8 encodingm and I can see the greek letters inside the fields.
The problem is that when i go to the site for the results, I get question marks instead of the greek characters.
I have searched a lot, and i found that there is a solution by adding mysql_query("SET NAMES utf8") after mysql_select_db.

Is that correct?
Also, i can not find the mysql_select_db in any of the files.

Thank you.
Similar Threads
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 18th, 2008
0

Re: Problem with Greek characters

Check what encoding you have set for your web page, If it is Latin 1 (ISO-8859-1) then the Greek characters will not be displayed.
You could check for without touching you code by browsing to your page and then (in Firefox 3) go to View -> Character Encoding and select UTF-8 since thats what it seems you are using, If the characters display correctly then you will just need add the following tag in the head section of all your HTML pages:-
html Syntax (Toggle Plain Text)
  1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
So that all the browsers treat it by default as a UTF-8 encoded page
Last edited by stephen84s; Sep 18th, 2008 at 2:56 am.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Sep 18th, 2008
0

Re: Problem with Greek characters

Hi Punkis,
character encoding mismatch can be a nightmare.
The database, tables and attributes all have charset and collation. Make sure it's set to UTF8 and utf8_general_ci (or utf8_your_language_code).

Then you need to make sure that you select a character set both when importing into and when reading from the database. You "SET CHARACTER SET utf8" or "SET NAMES utf8" - NAMES will set collation to default for given character set which may or may not be good for you (not if you used utf8_your_language_code).

Also, sometimes you think the data you import is in UTF8 while in fact, it isn't which adds even more fun into the game :-)

You can be sure that mysql_select_db() certainly is somewhere in your application. It wouldn't work without it.

http://dev.mysql.com/doc/refman/5.0/en/charset.html
(This is for MySQL 5, look around for other versions if you're running a different version.)
Reputation Points: 27
Solved Threads: 16
Junior Poster
petr.pavel is offline Offline
116 posts
since Mar 2008
Sep 18th, 2008
0

Re: Problem with Greek characters

thank you all for your replies.

I have proceed to a next stage now.

for stephen84s :into this progject, i have several departments that uses different databases.in one of them, that i do my tests, i did what you tell me.
my browser has for chractet encoding greek (windows-1253) i changed it to utf8 and i get question marks instead of greek letters. (the data are from mysql). that means that my page encoding isnt utf8 right?


to petr.pavel


My mysql charset is UTF8 and i changed the colation from latin_swedish (it was default) to utf8_general_ci and set the collation of the current table-field that contains the greek letters to utf8_general_ci.
Then i imported from a text file the queries i want to add.
The result is that there are no question marks, but wherever there is a greek letter is now invisible.

i feel that i get close.
thank you
Last edited by Punkis448; Sep 18th, 2008 at 9:45 am.
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 19th, 2008
0

Re: Problem with Greek characters

anyone knows a way ?
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 19th, 2008
0

Re: Problem with Greek characters

Click to Expand / Collapse  Quote originally posted by Punkis448 ...
anyone knows a way ?
Hi Punkis, my original comment still applies. You should focus on setting charset during import and setting charset in your application for regular usage.
Reputation Points: 27
Solved Threads: 16
Junior Poster
petr.pavel is offline Offline
116 posts
since Mar 2008
Sep 19th, 2008
0

Re: Problem with Greek characters

i did what you told me, but i didnt come to a solution. I googled and find out that there are so many users who did the same thing without a change. There must be something i do not do right.

P.S. When I import to mysql i do it from a notepad file that i save it to *****.sql

I used the default encoding and utf8 encoding but nothing
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 19th, 2008
0

Re: Problem with Greek characters

Click to Expand / Collapse  Quote originally posted by Punkis448 ...
When I import to mysql i do it from a notepad file that i save it to *****.sql
Try saving it to .html, open it in Firefox/Explorer, select encoding the way stephen84s described and see if your source is all right.

Can you post here the script you use for importing? Maybe the problem is there.

Also, when you import, export it using phpMyAdmin and again, change the extension to .html, open in FF/MSIE, set encoding to verify that the import is ok.
Reputation Points: 27
Solved Threads: 16
Junior Poster
petr.pavel is offline Offline
116 posts
since Mar 2008
Sep 19th, 2008
0

Re: Problem with Greek characters

Thank you petr.pavel for your support

1. I saved the following
to a html file. I uploaded in the sever and with default encoding Greek, it was displayed correctly. I changed browser encoding to UTF8 and i got question marks.
Then using Notepad again i saved it with utf-8 encoding and now it is displayed correctly with UTF8 encoding select by default to the browser.
MySQL Syntax (Toggle Plain Text)
  1. INSERT INTO `PHPAUCTIONXL_auctions` (`id`, `user`, `title`, `starts`, `description`, `pict_url`, `category`, `minimum_bid`, `reserve_price`, `buy_now`, `auction_type`,
  2. `duration`, `increment`, `location`, `location_zip`, `shipping`, `payment`, `international`, `ends`, `current_bid`, `closed`, `photo_uploaded`, `quantity`, `suspended`,
  3. `private`, `relist`, `relisted`, `num_bids`, `sold`, `shipping_terms`, `bn_only`, `adultonly`) VALUES('5227', '5', 'Αρχίδια ΑΡΧΙΔΙΑ βραστά VSX-AX5AI-S PIONEER',
  4. '20080905000444', '<a target="_blank" href="http://www.atsidas.gr/Product.aspx?ID=28&MenuID=27">View more info for this item</a>',
  5. 'http://www.atsidas.gr/ProductImages/0301000405s.jpg', '214', '0.00', '0.0000', '1100,00', '2', '55555555', '0.0000', 'Greece', 'NA', '2', 'By Mail\\nPaypal\\n', '1',
  6. '20240905173628', '0.0000', '0', '0', '1', '0', 'n', '0', '0', '0', 'n', 'none', 'n', 'n');


2. So, I guess some of my pages are not designed for utf8 encoding.
If it is so, that gives me two options.
A. To get the html code of all my pages, open it with notepad and encode it with utf8
B. To put the meta charset for utf8 to all of my pages. ( Have in mind that i did that for the pages that are used for the searching section, and also I did it with the combination of saving it with notepad in utf8 )
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008
Sep 19th, 2008
0

Re: Problem with Greek characters

Also, I import some items for the importing/exporting test you told me.
I have mysql and collations to utf8 general ci

1. Using the default encoding of notepad,I import the sql file and i got question marks. i did not exported it.
2. I saved the sql with utf8 encoding now. I uploaded it and mysql displays it right. I searched it through the site and it gave me question marks again. The encoding of browser is set to UTF8. Then i exported it from mysql, saved it into html, uploaded it, opened it and with greek encoding (default is right) utf8 gives me question marks
Reputation Points: 8
Solved Threads: 0
Light Poster
Punkis448 is offline Offline
31 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: join 2 tables with no common fields
Next Thread in MySQL Forum Timeline: SQL Injection





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC