Reputation: 22071
I'm importing data from Oracle database to MySQL tables.
I have set my MySQL table charset as utf8_general_ci
and database and table name with field column value set as utf-8
as well.
Now, When I fetch the result, it prints like, which is with ? sign
:
مرحبا العال� - 5
I have my utf value in column is مرØبا العالÙ
When I compare this string with Oracle string, it shows proper value - exact copy of Oracle database and there it shows perfect string in Arabic.
I have set my html meta with utf-8 as well
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
If I set mysql query as below, it shows junk characters:
mysql_query("SET NAMES utf8;");
mysql_query("SET CHARACTER_SET utf8;");
Followed everything possible found over stack and other sites, and still getting an error.
Please help !
Upvotes: 4
Views: 6321
Reputation: 479
with pdo you should have this
$_dbhandler = new PDO(PDO_DSN, DB_USERNAME, DB_PASSWORD,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8"));
Upvotes: 0
Reputation: 12389
Did you save the php-file without BOM? If not, try it. Potential issues with the UTF-8 BOM
Further try with 'utf-8' using single quotes and without SET CHARACTER_SET
mysql_query("SET NAMES 'utf8'");
and with charset utf-8 in the html-document header:
header("content-type: text/html; charset=utf-8");
Upvotes: 7