Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2181

Re: Displaying UTF-8-encoded strings from MySQL with PHP

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: Displaying UTF-8-encoded strings from MySQL with PHP
Date 2011-06-15 06:53 -0400
Organization A noiseless patient Spider
Message-ID <ita2uk$a3f$1@dont-email.me> (permalink)
References <e1fa9d06-3720-4489-9667-14bba4aa3506@d1g2000yqm.googlegroups.com> <ita1dk$1b8$1@dont-email.me>

Show all headers | View raw


On 6/15/2011 6:26 AM, "Álvaro G. Vicario" wrote:
> El 15/06/2011 12:18, Luke escribió/wrote:
>> I'm trying to migrate my project from ISO-8859-1 (Western Europe) to
>> UTF-8. I *can* write special characters as regular text in my php-
>> files, I can use special characters in echo-statements and I can even
>> use special characters in .ini-files, load them, and display them. But
>> when I load Strings with special characters from MySQL and display
>> them, the string's "broken".
>>
>> I've tried many things: First of all, I use
>>
>> <?xml version="1.0" encoding="utf-8" ?>
>> and
>> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
>>
>> in the markup. In the database I tried to set my table's collation to
>> "utf8_general_ci". Also I tried the following functions:
>>
>> mysql_query("SET NAMES ‘utf8′");
>> mysql_set_charset('utf8');
>> mb_internal_encoding("UTF-8");
>>
>> all not at the very beginning of my script, but before I queried the
>> database and before I printed the results. I still keep getting
>> 'wierd' characters.
>>
>> Does anyone have an idea what I can do?
>
> Here's quite a complete list of the required steps:
>
> http://www.itnewb.com/v/UTF-8-Enabled-Apache-MySQL-PHP-Markup-and-JavaScript
>
>
> Whatever, are you sure that your data is actually stored as valid UTF-8
> after the migration?
>
> The HEX() function can be handy:
>
> http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_hex
>
>
>

Álvaro, I admit I'm not great at UTF-8.  This is a great guide if you 
have your own server and want everything in UTF-8.  However, do you know 
of a similar reference for those who use shared servers and/or don't 
want everything to default to UTF-8?

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 03:18 -0700
  Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-15 12:26 +0200
    Re: Displaying UTF-8-encoded strings from MySQL with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-15 06:53 -0400
      Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-15 13:57 +0200
        Re: Displaying UTF-8-encoded strings from MySQL with PHP Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-15 12:07 -0400
          Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-16 09:29 +0200
    Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 05:56 -0700
      Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 06:05 -0700
        Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 06:23 -0700
          Re: Displaying UTF-8-encoded strings from MySQL with PHP Luke <kickingjesus@gmail.com> - 2011-06-15 06:50 -0700
            Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-15 16:17 +0200
              Re: Displaying UTF-8-encoded strings from MySQL with PHP Tim Streater <timstreater@waitrose.com> - 2011-06-15 15:26 +0100
  Re: Displaying UTF-8-encoded strings from MySQL with PHP Jo Schulze <antispam@feuersee.de> - 2011-06-16 23:34 +0200
    Re: Displaying UTF-8-encoded strings from MySQL with PHP "Álvaro G. Vicario" <alvaro.NOSPAMTHANX@demogracia.com.invalid> - 2011-06-17 13:23 +0200

csiph-web