how to (a) write non-latin text in phpMyAdmin and (b) show it on a browser using php
I have seen some solutions but I can't seem to understand how to make it work.
(a) in phpMyAdmin I can select between these 2 options for hebrew:
- hebrew_general_ci
- hebrew_bin
after picking one of these - I can see in phpMyAdmin the characters properly.
What are the differences? and shouldn't I be picking utf-8 instead?
(b) Regarding the PHP - the html file can show me hebrew because I have this line encoded:
<meta http-equiv="Content-Type" content="开发者_如何学运维text/html; charset=utf-8">
and if I would write "echo אבגדה" (non-latin) it will also work.
The problem is with taking the database data and show it properly (it shows "??????").
here is the simple code:
<?php
$con = mysql_connect("localhost","root","my_password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("boomerang", $con);
$result = mysql_query("SELECT * FROM words");
while($row = mysql_fetch_array($result))
{
echo $row['blabla'];
}
mysql_close($con);
?>
What do I need to add to make it work?
Try changing the collation to utf8_bin, and changing the encoding line to
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-8-i">
精彩评论