Re: Character set problems

From: Date: Fri, 04 Apr 2008 13:32:39 +0000
Subject: Re: Character set problems
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-272522@lists.php.net to get a copy of this message
mysql_query("SET NAMES utf8"); This above line of code fixed my character problems. Yay! Was curious though - - - -is there a place somewhere in the cPanel or myPHPAdmin on my ISP (www.bluehost.com), where I can just have this happen automatically, or do I need to put this in my code everywhere I make a SQL call? On Thursday, April 03, 2008, at 11:14PM, "Robert Cummings" <robert@interjinn.com> wrote: > >On Thu, 2008-04-03 at 21:56 -0700, Rob Gould wrote: >> I'm having a hard time figuring out why my character sets and data look when when >> viewed in phpAdmin when browsing the table-columns, but then I go to show the data on my web-page >> with PHP, I get garbage-characters where I should be seeing apostrophs and special >> foreign-characters. >> >> I copied all the header-data from the phpAdmin pages: >> >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >> >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >> <html xmlns="http://www.w3.org/1999/xhtml" >> xml:lang="en" lang="en" dir="ltr"> >> <head> >> >> <meta http-equiv="Content-Type" content="text/html; >> charset=utf-8" /> >> >> >> where the characters all show up properly, and I've put this on my web-page. >> >> Here's what I know about my database, according to myphpadmin: >> >> >From the phpAdmin settings page: >> >> MySQL charset: UTF-8 Unicode (utf8) >> MySQL connection collation: utf8_unicode_ci >> >> >From the Structure tab for my table: >> >> Type: MyISAM >> Collation: utf8_unicode_ci >> >> >> So, based on the headers I'm using, and the myphpAdmin settings, is there something >> I'm missing? I guess I was assuming since the headers are set for utf-8, and the "MySQL >> charset = UTF-8 Unicode (utf8)", that everything would be compatible. > >Do you have this in your php.ini? > > default_charset = "utf-8" > >Or if you want... the following in a .htaccess or virtual host config: > > php_value default_charset utf-8 > >You can even manually output it from within your PHP code: > > header( 'Content-Type: text/html; charset=utf-8' ); > >Cheers, >Rob. >-- >http://www.interjinn.com >Application and Templating Framework for PHP > > >

« previous php.general (#272522) next »