Re: question about database field-types and special characters

From: Date: Fri, 15 Feb 2008 05:10:14 +0000
Subject: Re: question about database field-types and special characters
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-269352@lists.php.net to get a copy of this message
On Thu, 2008-02-14 at 23:59 -0500, Robert Cummings wrote: > 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. Wouldn't create a site with anything but UTF-8. ^^^^^^^^ :) 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. | `------------------------------------------------------------'

« previous php.general (#269352) next »