My database collation is utf8_general_ci.
My table collation is utf8_general_ci.
My table's `scope` field collation is utf8_general_ci.
My html page has <meta charset="utf-8">
But when I echo $query[10]['scope'];
instead of getting (’) I get (�)
In phpMyAdmin when looking at the same data I see the proper quote character.
The phpmyadmin page is also specifying utf-8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
What am I doing wrong?
This has been a pain in my side since I first started using php/mysql 7 years ago and I seem to be no closer to having a clue.
UTF 8 mysql problem with quote character
Moderator: General Moderators
-
thinsoldier
- Forum Contributor
- Posts: 367
- Joined: Fri Jul 20, 2007 11:29 am
- Contact:
UTF 8 mysql problem with quote character
Warning: I have no idea what I'm talking about.
Re: UTF 8 mysql problem with quote character
Maybe this is not the case but to be sure add header in php file (before any output)
Also save the file in UTF-8
as for html meta you could try ..
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Is this happening only for the single quote character? How do you output the string? Have tried to loop through letters of string and see their ASCII values (with ord) ?
Code: Select all
<?php header('Content-Type: text/html; charset=utf-8'); ?>as for html meta you could try ..
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Is this happening only for the single quote character? How do you output the string? Have tried to loop through letters of string and see their ASCII values (with ord) ?
-
thinsoldier
- Forum Contributor
- Posts: 367
- Joined: Fri Jul 20, 2007 11:29 am
- Contact:
Re: UTF 8 mysql problem with quote character
Turns out I needed to do this:
mysql_query('SET NAMES utf8;');
mysql_query('SET CHARACTER SET utf8;');
mysql_query('SET NAMES utf8;');
mysql_query('SET CHARACTER SET utf8;');
Warning: I have no idea what I'm talking about.