Re: question about database field-types and special characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2008-02-14 at 18:47 -0800, Rob Gould wrote:
> I've got a PHP application that pulls in data from a mySQL database.  The data is a series of wine producers, and many of them have special foreign characters over the a's and o's.  
> 
> When I go and view the data from my database using myPHPAdmin, the characters look fine, but when I pull the data into my web-page the special characters get messed up.
> 
> For whatever reason, when I first set up the database, someone told me to preserve special characters by setting my collation for the wine-producer field to "latin1_swedish_ci".  The data seems to be in there ok, so at least that works.
> 
> Should I have used utf-8 instead?  Can I set something in the doctype or header of my web-page to make it so that my website displays latin1_swedish_ci-based characters properly, or should I change my database field-type to be something different?  My main fear is messing up the database (I'll back up first if I have to chance the field collation)

SOunds like your website is UTF8 and your DB as you say is latin1. You
have a few choices. You can set the php.ini config value:

    default_charset = "iso-8859-1"

You can also set the meta tag (probably best to set the PHP config and
the meta tag):

    <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />

Or, and this is what I would do, convetr your database to UTF-8. That
way you're prepared for the rest of the world. In this day and age I
would creat a site with anything but UTF-8.

Here's some reading for you:

    http://www.joelonsoftware.com/articles/Unicode.html

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux