By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

accents being replaced with garbage in text fields on forms

P: n/a
i have php form on an apache server that sends an email and stores in
a mysql database once it is submitted

when someone enters a name with an accent over a letter it mangles the
text

for example

the user enters Montréal and the email i get ends up looking like
Montréal, it also stores it in the database this way

any ideas on what is happening here and how i can correct it?

thanks

Sep 24 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
..oO(ca******@gmail.com)
>i have php form on an apache server that sends an email and stores in
a mysql database once it is submitted

when someone enters a name with an accent over a letter it mangles the
text

for example

the user enters Montréal and the email i get ends up looking like
Montréal, it also stores it in the database this way

any ideas on what is happening here and how i can correct it?
Something interprets UTF-8 encoded data as ISO-8859-1.
What encoding do you use on your pages and in your database?

Micha
Sep 24 '08 #2

P: n/a
On 24 Sep, 17:00, "canaj...@gmail.com" <canaj...@gmail.comwrote:
i have php form on an apache server that sends an email and stores in
a mysql database once it is submitted

when someone enters a name with an accent over a letter it mangles the
text

for example

the user enters Montréal and the email i get ends up looking like
Montréal, it also stores it in the database this way

any ideas on what is happening here and how i can correct it?

thanks
Try issuing SET NAMES UTF8 after connecting to the database, before
running any other queries.
Sep 25 '08 #3

P: n/a
On Sep 24, 5:00*pm, "canaj...@gmail.com" <canaj...@gmail.comwrote:
i have php form on an apache server that sends an email and stores in
a mysql database once it is submitted

when someone enters a name with an accent over a letter it mangles the
text

for example

the user enters Montréal and the email i get ends up looking like
Montréal, it also stores it in the database this way

any ideas on what is happening here and how i can correct it?

thanks
This sounds like a character encoding mismatch between the database
and the HTMl pages. The most usual cause is the web page being
encoded as iso-8859-1 (which I believe is the default format for
Dreamweaver), and the database being in UTF-8, but any character
encoding mismatch will produce similar results. Make sure that both
your database and web pages are using the same encoding, these days
this generally should be UTF-8.

UTF-8 is the preferred encoding because a valid ASCII string is also a
valid UTF-8 string, giving good backward compatibility. It also
supports the full set of Latin alphabet accents and characters in a
uniform way, and will even support far eastern languages (albeit in a
way that's quite inefficient).
Sep 25 '08 #4

P: n/a
On Sep 25, 6:28*am, Gordon <gordon.mc...@ntlworld.comwrote:
On Sep 24, 5:00*pm, "canaj...@gmail.com" <canaj...@gmail.comwrote:
i have php form on an apache server that sends an email and stores in
a mysql database once it is submitted
when someone enters a name with an accent over a letter it mangles the
text
for example
the user enters Montréal and the email i get ends up looking like
Montréal, it also stores it in the database this way
any ideas on what is happening here and how i can correct it?
thanks

This sounds like a character encoding mismatch between the database
and the HTMl pages. *The most usual cause is the web pagebeing
encoded as iso-8859-1 (which I believe is the default format for
Dreamweaver), and the databasebeingin UTF-8, but any character
encoding mismatch will produce similar results. *Make sure that both
your database and web pages are using the same encoding, these days
this generally should be UTF-8.

UTF-8 is the preferred encoding because a valid ASCII string is also a
valid UTF-8 string, giving good backward compatibility. *It also
supports the full set of Latin alphabetaccentsand characters in a
uniform way, and will even support far eastern languages (albeit in a
way that's quite inefficient).
thanks for the lesson guys :)

the page was already set to utf-8 in a meta tag, so I added the
following to the form tag:

accept-charset="utf-8"

for good measure I made sure the mysql table would accept the
characters by resetting the table with:

ALTER TABLE tablename DEFAULT CHARACTER SET utf8

hopefully this will take care of my problem
Sep 25 '08 #5

P: n/a
unfortunately the changes i made weren't enough to correct my problem,
however I did come across this page:

http://www.nicknettleton.com/zine/ph...f-8-cheatsheet

and once I made the changes to my php.ini everything started working

thanks again for the advise
Sep 29 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.