note 71627 added to function.mysql-client-encoding
| From: | bartullus at wp dot pl | Date: | Fri, 08 Dec 2006 14:35:09 +0000 |
| Subject: | note 71627 added to function.mysql-client-encoding | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120433@lists.php.net to get a copy of this message | ||
For some reason given entry in php.ini:
default_charset = "ISO-8859-2"
nor
default_charset = "latin2"
doesn't work.
Every time you run:
$charset= mysql_client_encoding($dbh);
echo $charset;
from PHP connecting to MySQL you will get 'latin1'.
Even if all HTML/PHP pages are stored as UTF8 with header:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
and MySQL server is everywhere UTF8:
character_set_client | utf8
character_set_connection | utf8
character_set_database | utf8
character_set_filesystem | binary
character_set_results | utf8
character_set_server | utf8
character_set_system | utf8
adding "SET NAMES latin2" and "SET CHARACTER SET latin2" into your PHP to MySQL
connection you will always get question marks after doing select.
I also tried all the tips from this page and did not succeed as others stated 'it worked for
me' - blah...spent 6 hours on that.
THE ONLY solution that "worked for me" and for others using latin2-iso-8859-2 (i'm
from Poland) is to put single line into your SQL script with many inserts:
set name LATIN1;
After that, you can run a SQL script from QUERY BROWSER with the latin2 characters in inserts.
After only that, when you query those fields from PHP page via select you will get NO question marks
and garbage.
If you use 'mysql' command line tool instead of QUERY BROWSER to run insert script you
must remove "set names latin1" from the beginning of the script because of the error while
processing that line. Instead of that run "set names latin1" separatelly and then run the
insert script.
'mysql' works fine with "set names latin2" but only with singleline, manual
inserts.
'mysql' command client works fine after switching to "set names latin2" but
MySQL Query Browser do not. Query Browser v.1.2.6 beta is not great for some other reasons not worth
mentioning here.
My configuration is:
Windows 2000
Apache2.2
MySQL 5.0.27
MySQL client shows 5.1.11
PHP5.2.0
and I needed to run insert script to fullfil dictionaries with initial data.
----
Server IP: 83.64.128.68
Probable Submitter: 212.126.11.11 (proxied: unknown)
----
Manual Page -- http://www.php.net/manual/en/function.mysql-client-encoding.php
Edit -- https://master.php.net/note/edit/71627
Del: integrated -- https://master.php.net/note/delete/71627/integrated
Del: useless -- https://master.php.net/note/delete/71627/useless
Del: bad code -- https://master.php.net/note/delete/71627/bad+code
Del: spam -- https://master.php.net/note/delete/71627/spam
Del: non-english -- https://master.php.net/note/delete/71627/non-english
Del: in docs -- https://master.php.net/note/delete/71627/in+docs
Del: other reasons-- https://master.php.net/note/delete/71627
Reject -- https://master.php.net/note/reject/71627
Search -- https://master.php.net/manage/user-notes.php