My table looks like this-
province_id int(11)
province_title char(200) utf8_general_ci
parent int(8) int(2)
I have inserted a lot of data direct from phpMyadmin (not from php page). but when i retrieve those data and show them in php page, then there are problems with special characters.
like-
Québec shows - Qu�bec.
my html header looks like -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
i think the problem might have happened while inserting the data. how can i convert those data in phpmyadmin? any help?
seems like you're not using utf-8 everywhere so your data got messed up at some point. depending on what exactly you're doing, you'll have to change/add one or more of the following points (most likely it's the SET CHARSET/mysql_set_charset wich you forgot):
tell MySQL to use utf-8. to do this, add this to your my.cnf:
collation_server = utf8_unicode_ci character_set_server = utf8
before interacting with mysql, send this two querys:
SET NAMES 'utf8'; CHARSET 'utf8';
or, alternatively, let php do this after opening the connection:
mysql_set_charset('utf8', $conn); // when using the mysql_-functions mysqli::set_charset('utf8') // when using mysqli
set UTF-8 as the default charset for your database
CREATE DATABASE `my_db` DEFAULT CHARACTER SET 'utf8';
do the same for tables:
CREATE TABLE `my_table` ( -- ... ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
assuming the client is a browser, serve your content as utf-8 and the the correct header:
header('Content-type: text/html; charset=utf-8');
to be really sure the browser understands, add a meta-tag:
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
and, last but not least, tell the browser to submit forms using utf-8
<form accept-charset="utf-8" ...>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With