spanish accents

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alexislalas
Forum Commoner
Posts: 44
Joined: Sun Feb 19, 2006 10:09 pm

spanish accents

Post by alexislalas »

hello to all.

im reading from a mysql database. inside the DB the characters are fine, when i check it on localhost they are fine. but once i upload it to the internet, the accents turn into question marks.


ive tried <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> and <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> and it doesnt work.


anyone here can help me? thanks
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I think this can be changed with the browser (Character Encoding).
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Make them entities.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

feyd wrote:Make them entities.
That shouldn't be necessary.

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
That is the correct charset. My guess is the webserver is sending a conflicting header which takes precedence over this meta element. Try adding a header to your code to stop this behaviour.

Code: Select all

header('Content-Type: text/html; charset=iso-8859-1');
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post by Cameri »

UTF-8 could get the work done too pal... One time I got into an irc channel, and the users there were using accents, and only those who had clients that supported UTF-8 could see them (I wasn't using mIRC back then).
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

That may be so but the correct charset for Castellano is iso-8859-1.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

the correct charset for Castellano is iso-8859-1.
Incorrect. Character encodings are simply mappings of bytes to characters, so as long as a charset provides all the characters necessary to express a language, it is usable. Thus, there are no "correct" charsets, but there are "incorrect"/"inefficient"/"rarely used" ones, i.e. you can't (without great difficulty) use Latin-1 to write Arabic.

While I strongly recommend you switch to UTF-8, keep in mind that you will have to convert characters from iso-8859-1 to UTF-8 using iconv if you choose to go that path. For now, take bokehman's advice and try sending the proper header.
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Post by emmbec »

I was having the same problem and I just wanted to let you know that my problem was solved using this code at the begining of my page:

Code: Select all

<?php
header('Content-Type: text/html; charset=iso-8859-1');
?>

In MySQL I was using latin1_general_ci Collation for my "Name" Field.

Thanx Bokehman
User avatar
Jaxolotl
Forum Contributor
Posts: 137
Joined: Mon Nov 13, 2006 4:19 am
Location: Argentina and Italy

Post by Jaxolotl »

Here you may find some answers

[SOLVED]problem saving record in UTF-8
Post Reply