Re: Greek Characters from MySQL to PHP to the Browser: ??????

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Wells wrote:
> Hi Everybody,
> 
> Despite all of my Googling and noodling, I can't seem to figure this
> out, and am hoping someone might be able to point me in the right
> direction.
> 
> Scenario:
> - Running Apache 1.3 on OSX 10.4, PHP 5.1.4, MySQL 5.0.19
> - Greek text is stored in a MySQL database, encoding set to UTF-8
> - From within a db admin like CocoaMySQL, the greek text looks normal
> - PHP queries the db table for the greek text
> - no matter how I echo the text to screen (see below), it only
> produces '?????' marks
> 
> What I've tried:
> - force utf-8 headers to be sent  ---> header("Content-type:
> text/html; charset=UTF-8");
> - indicate utf-8 in the meta tag --> <meta http-equiv=Content-Type
> content="text/html; charset=utf-8" />
> - simpley echo the string as is --> echo $greek_string;
> - wrap output in htmlentities() --> echo htmlentities($greek_string,
> ENT_NOQUOTES, 'UTF-8');
> - wrap output in utf8_decode() --> echo utf8_decode($greek_string);
> - If I copy and paste greek characters from the db table into a string
> in my PHP script, and output that, it works just FINE, without any
> htmlentities() or other functions.
> 
> I'm at a loss.  What am I doing wrong?

odds are your not specifying a charset for the connection ... and that the default
connection charset is ISO-8859-1 (known as Latin1 in MySQL iirc).

try running these 2 queries after you connect to the DB (might not work, it depends on
on MySQL version):

$CharSet = 'UTF-8';
$qry1 = "SET NAMES '{$CharSet}'");
$qry2 = "SET CHARACTER SET {$CharSet}";



> 
> Thanks in advance,
> John W
> 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux