in most php apps, they use a separate database connection class. just
locate the function where it does mysql_select_db(), you can place the
line right after it selects the db. this will set name for each
connection, so no need to specifically set name every time you execute
a query.

or if you have access to my.cnf, add.. "init-connect='SET NAMES utf8'"
under the [mysqld] section.

happy utf8ing


~viraj

On Fri, Apr 4, 2008 at 3:32 PM, Rob Gould <[EMAIL PROTECTED]> wrote:
>         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" <[EMAIL 
> PROTECTED]> 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
>  >
>  >
>  >
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

Reply via email to