Problem with Greek characters

Reply

Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Problem with Greek characters

 
0
  #1
Sep 18th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: Problem with Greek characters

 
0
  #2
Sep 18th, 2008
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:-
  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.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 100
Reputation: petr.pavel is an unknown quantity at this point 
Solved Threads: 14
petr.pavel's Avatar
petr.pavel petr.pavel is offline Offline
Junior Poster

Re: Problem with Greek characters

 
0
  #3
Sep 18th, 2008
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.)
Petr 'PePa' Pavel

The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Re: Problem with Greek characters

 
0
  #4
Sep 18th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Re: Problem with Greek characters

 
0
  #5
Sep 19th, 2008
anyone knows a way ?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 100
Reputation: petr.pavel is an unknown quantity at this point 
Solved Threads: 14
petr.pavel's Avatar
petr.pavel petr.pavel is offline Offline
Junior Poster

Re: Problem with Greek characters

 
0
  #6
Sep 19th, 2008
Originally Posted by Punkis448 View Post
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.
Petr 'PePa' Pavel

The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Re: Problem with Greek characters

 
0
  #7
Sep 19th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 100
Reputation: petr.pavel is an unknown quantity at this point 
Solved Threads: 14
petr.pavel's Avatar
petr.pavel petr.pavel is offline Offline
Junior Poster

Re: Problem with Greek characters

 
0
  #8
Sep 19th, 2008
Originally Posted by Punkis448 View Post
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.
Petr 'PePa' Pavel

The more information you give the more relevant answer you get.
Please consider using "Add to ... Reputation" and mark your thread as Solved if you found what you were looking for. By giving feedback you help others.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Re: Problem with Greek characters

 
0
  #9
Sep 19th, 2008
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.
  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 )
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 31
Reputation: Punkis448 is an unknown quantity at this point 
Solved Threads: 0
Punkis448 Punkis448 is offline Offline
Light Poster

Re: Problem with Greek characters

 
0
  #10
Sep 19th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MySQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC