468,771 Members | 1,939 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

how to show greek letters

15
Hi all,
I'm having trouble trying to enter/retrieve Greek characters.
I have an astronomical dbase in MySQL. As you may know, lots of sky objects have Greek letter names (alpha Centauri, etc) but I want to enter these - and have the user see them - as the actual greek characters. Copying and pasting from character map doesn't work (if I copy the greek letter gamma, when I paste it into the field in PHPMyAdmin it comes out as "g" and likewise when the query is executed on the web page through PHP). Setting the field type to "Binary" and entering 0x65 causes the field on the web page to be blank.
I have set the collation for utf-8 in PHPMyAdmin, and the charset to utf-8 on the web page.
I need those Greek letters!
Cheers,
Starman
Sep 24 '07 #1
6 15917
Atli
5,058 Expert 4TB
Hi Starman.

If your database is set to use UTF-8 this must be a problem with your PHP script.

Are you using any functions on the string before you output them? Like the htmlentities() function, for example, will assume the string is ISO-8859-1 unless you specify the charset.

If you could show us the code, we could help you spot the problem, if it is there.
Sep 24 '07 #2
pbmods
5,821 Expert 4TB
Heya, Starman.

What's your connection encoding?

Try adding these lines just after you connect to your MySQL database:
Expand|Select|Wrap|Line Numbers
  1. mysql_query("SET NAMES 'utf8'", $dbConn);
  2. mysql_query("SET CHARACTER SET 'utf8'", $dbConn);
  3.  
where $dbConn is your MySQL connection resource.
Sep 25 '07 #3
starman
15
Heya, Starman.

What's your connection encoding?

Try adding these lines just after you connect to your MySQL database:
Expand|Select|Wrap|Line Numbers
  1. mysql_query("SET NAMES 'utf8'", $dbConn);
  2. mysql_query("SET CHARACTER SET 'utf8'", $dbConn);
  3.  
where $dbConn is your MySQL connection resource.
Hi,
Thanks for your quick reply! This is the page coding (it's just a trial page at the moment). The include file works as it's supposed to, so I don't think the problem lies there. It holds the dbConnect function. 'Close' is the name of the table (I've just had a thought - could "close" be a reserved word somewhere?)
[PHP]<?php
include('connection.inc.php');
$conn = dbConnect();
mysql_query("set names 'utf8'", $conn);
mysql_query("set character set 'utf8'", $conn);
$sql = "select * from close";
$res = mysql_query($sql) or die (mysql_error());
$numrows = mysql_num_rows($res);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- Created on: 24/09/2007 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<p>A total of <?php echo $numrows; ?> records.</p>
<table width=100%>
<?php
while ($row = mysql_fetch_assoc($res))
{
?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['constellation']; ?></td>
</tr>
<?php } ?>
</body>
</html>[/PHP]
Sep 26 '07 #4
starman
15
Hi again,
Just to say I've solved the problem! My particular solution is actually quite complicated, since the circumstances are not simply one-for-one; sometimes, a greek letter will need to be followed by a number as well, and I need roman letters and numbers too! However, if anyone needs a simple one-to-one conversion function, I can easily adapt (i.e., vastly simplify) my existing oneinto a "switch" process using PHP. If you're interested, drop me a line at:
[removed]
Sep 27 '07 #5
pbmods
5,821 Expert 4TB
Heya, Starman.

For your protection, I have removed your email address from your post.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sep 28 '07 #6
starman
15
Just to say "Thanks" everyone who helped! Much appreciated.
Sep 28 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Vangelis Natsios | last post: by
9 posts views Thread by PAN | last post: by
1 post views Thread by interuser | last post: by
2 posts views Thread by Dave | last post: by
8 posts views Thread by =?gb2312?B?yMvR1MLkyNXKx8zs0cSjrM37vKvM7NHEsru8+7z | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.