473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Character Sets in PHP + MySQL

Can anyone advise me on the use of UTF-8 in PHP and MySQL? What is the best
approach?

I would prefer to store HTML extended characters in the database as UTF-8,
but I can only get the HTML to display properly if I store character
entities (eg. ř).

Every table in my database is set to UTF-8. The web page generated by PHP is
declared as UTF-8. The HTTP response header from the server is UTF-8. The
character set of the database connection is defined as UTF-8.

I've tried using the PHP function "htmlentities" to convert the characters,
but it doesn't work for the complete UTF-8 character set.

What am I missing? Do I need to do something with the Multibyte string
functions?
Dec 1 '05 #1
2 1774
Kevin Laurence wrote:
Can anyone advise me on the use of UTF-8 in PHP and MySQL? What is the best
approach?

I would prefer to store HTML extended characters in the database as UTF-8,
but I can only get the HTML to display properly if I store character
entities (eg. ř).

Every table in my database is set to UTF-8. The web page generated by PHP is
declared as UTF-8. The HTTP response header from the server is UTF-8. The
character set of the database connection is defined as UTF-8.

I've tried using the PHP function "htmlentities" to convert the characters,
but it doesn't work for the complete UTF-8 character set.

What am I missing? Do I need to do something with the Multibyte string
functions?

Are you sending a header which tells the browser you will be sending it
UTF-8 ?
header('Content-Type: text/html; charset=utf-8');

In the HTML you could also add:
<meta http-equiv="Charset" content="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Dec 2 '05 #2
Yes. The response header includes 'Content-Type: text/html; charset=utf-8'.

"Juliette" <jr*********@jokeaday.net> wrote in message
news:43***********************@news.wanadoo.nl...
Kevin Laurence wrote:
Can anyone advise me on the use of UTF-8 in PHP and MySQL? What is the
best approach?

I would prefer to store HTML extended characters in the database as
UTF-8, but I can only get the HTML to display properly if I store
character entities (eg. ř).

Every table in my database is set to UTF-8. The web page generated by PHP
is declared as UTF-8. The HTTP response header from the server is UTF-8.
The character set of the database connection is defined as UTF-8.

I've tried using the PHP function "htmlentities" to convert the
characters, but it doesn't work for the complete UTF-8 character set.

What am I missing? Do I need to do something with the Multibyte string
functions?

Are you sending a header which tells the browser you will be sending it
UTF-8 ?
header('Content-Type: text/html; charset=utf-8');

In the HTML you could also add:
<meta http-equiv="Charset" content="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Dec 2 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ghasem | last post by:
Dear all, Hello to all the great minds of php. My humble question is regarding the phpmyadmin. As you know the welcome screen of phpmyadmin allows one to choose the language. My question is this:...
7
by: WindAndWaves | last post by:
Hi Folk Here I am writing my first php / mysql site, almost ready, and now this... charactersets.... The encoding that I use on my webpage is: <META HTTP-EQUIV="content-type"...
0
by: Tumurbaatar S. | last post by:
Hi, I'm running MySQL 3.23.55 on WinXP and have some problem using non latin charset. I've added these 2 lines under group of my.ini: character-sets-dir = c:/mysql/share/charsets/...
0
by: Thiko | last post by:
Hi According to the official mysql manual: http://www.mysql.com/doc/en/Charset-SHOW-CHARSET.html The syntax to show all available character sets is the SHOW CHARACTER SET command. It takes...
2
by: Thiko | last post by:
Hi Im very new to mysql - My experience of MySQL revealed some issues with languages like Czech, Hungarian, Finnish and Polish. There was also a question as to whether it could support Chinese....
4
by: siliconmike | last post by:
All I know is that there are 8 bit numbers from 0 to 255 mapped to characters like A, B, C, D and some strange looking ones (like the ones used to make boxes in old PC text modes) all these being...
37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
1
by: Kevin Laurence | last post by:
Can someone help me with a character set/encoding problem? I am using a MySQL database with PHP to store the name "Bedrich". Notice the letter "r" in the name. It has an accent, just as it does...
3
by: Klaus Herzberg | last post by:
Hi, I come from the "dark side" php/mysql and there often problems with character sets (utf-8, latin...) and storing data in datebase. Exists in the world of dot.net and ms-sql-server similiar...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.