473,322 Members | 1,493 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,322 software developers and data experts.

accents being replaced with garbage in text fields on forms

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
5 3593
..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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ratlhead | last post by:
Hey all, I'm attempting to do some form processing on a server that has register_globals off, however, I've run into a confusing situation and need some help. Basically, the form is a...
5
by: chepiok | last post by:
I'd like to send email containing accents (french one) using PHP command mail(). The content of these emails are store in text files. I'de like to know : - text file format (encoding, with...
2
by: c w | last post by:
Can anyone point me in the right direction? Using Oracle 9i, Pro*C and Excel. I am trying to print french accents from the Oracle DB using Pro*C to extract the necessary info and sent the result...
2
by: Ghislain Benrais | last post by:
Hi everybody, I have xml documents with external entities for my accents that I want to output properly with php function domxml_open_file. I can't get my accents on a linux-apache server (I get...
2
by: AmigoFd | last post by:
Hello, This problem is really driving me crazy ... * I have a mySql database which is latin1_swedish_ci * In my web.config I have: <globalization requestEncoding="ISO-8859-2"...
3
by: jim | last post by:
Hi, I can't gte accents in the subject and body fields of an e-mail ! This is my code : document.location.href = 'mailto:webmaster@mysite.com?subject=the subject is éléphant&body=elephant is...
1
by: bssjohn | last post by:
Dear All, I have developing a French website using PHP & Ajax. In that I tried to display some French texts from mysql database using Ajax. Form local I got the text from db with Correct accents...
5
by: Amy L. | last post by:
I am at an absolute loss on what is going on here. I have a text file with some Spanish writing. Some of the characters have accents. I have not found anyway to read this text file and echo the...
5
by: arty | last post by:
i have set up a xhr , all the accents on the page are showed ok on ff an safari function _cms() { cms.open("GET", 'cms.php', true); cms.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.