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


Groups > comp.lang.php > #3142

Re: PHP, MySQL and UTF-8?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="ISO-8859-1"
Message-ID <1537384.qVoOGUtdWV@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <php@PointedEars.de>
Organization PointedEars Software (PES)
Date Tue, 13 Sep 2011 16:53:45 +0200
User-Agent KNode/4.4.11
Content-Transfer-Encoding 7Bit
Subject Re: PHP, MySQL and UTF-8?
Newsgroups comp.lang.php
References <9d6ralFrpkU1@mid.uni-berlin.de>
Followup-To comp.lang.php
MIME-Version 1.0
Lines 34
NNTP-Posting-Date 13 Sep 2011 16:53:46 CEST
NNTP-Posting-Host 96d1c008.newsspool1.arcor-online.net
X-Trace DXC=Q;8OdC;@<M]Fm0Y?OE@2^Xic==]BZ:af^4Fo<]lROoRQ<`=YMgDjhgRLL;M;5WHcBPDZm8W4\YJN\UFDj8T]K0?SDmniOZG;K0[GF4USRUf`3_
X-Complaints-To usenet-abuse@arcor.de
Xref x330-a1.tempe.blueboxinc.net comp.lang.php:3142

Followups directed to: comp.lang.php

Show key headers only | View raw


Robert Latest wrote:

> I have UTF-8 characters in my database. They're there, I can see them in
> a MySQL dump as well as in phpmyadmin.
> 
> When I retrieve this data from the db and output it via print(), all I get
> is question marks. These come from the server because I see them also in
> wget's output.

As for the wget output, your console might not be UTF-8-compliant, or you 
might not have declared the proper character encoding for the HTTP resource 
and the resource type (e. g., HTML) requires you to escape them then, which 
you also failed to do.

> In phpmyadmin I see the correct characters in my db. When I insert them
> literally in my HTML they come out as expected. When I print() them as
> string literals in php, they come out correctly as well.

This and
 
> I think I'm opening the db correctly:
> 
> $c = new PDO("mysql:host=$host;dbname=$dbname;port=$port;charset=UTF-8",
>             $user, $pass);

suggests that the Content-Type header field of the HTTP response for your 
Web site has the wrong value.  And I think that is a FAQ.
 

PointedEars
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
 -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

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


Thread

PHP, MySQL and UTF-8? Robert Latest <boblatest@yahoo.com> - 2011-09-12 16:46 +0000
  Re: PHP, MySQL and UTF-8? Jerry Stuckle <jstucklex@attglobal.net> - 2011-09-12 15:30 -0400
  Re: PHP, MySQL and UTF-8? "Peter H. Coffin" <hellsop@ninehells.com> - 2011-09-12 14:31 -0500
    Re: PHP, MySQL and UTF-8? "A" <a@a.a> - 2011-09-12 22:27 +0200
  Re: PHP, MySQL and UTF-8? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-09-13 16:53 +0200

csiph-web