ID: 35183
Updated by: [EMAIL PROTECTED]
Reported By: lzx21cn at 21cn dot com
-Status: Closed
+Status: Bogus
Bug Type: MySQL related
Operating System: linux debian unstable
PHP Version: 4.4.0-4
New Comment:
No PHP bug -> bogus.
Previous Comments:
------------------------------------------------------------------------
[2005-11-12 10:54:44] lzx21cn at 21cn dot com
php file must inclue this line
<?php
/* set client connection to utf8 */
mysql_query("SET NAMES utf8");
?>
Thank you very much!
------------------------------------------------------------------------
[2005-11-12 09:33:28] [EMAIL PROTECTED]
Try to build PHP using official sources and the latest release.
Please tell us the version of MySQL you're using.
------------------------------------------------------------------------
[2005-11-12 07:17:14] [EMAIL PROTECTED]
can't repeat (tested with MySQL 4.1 and 5.0):
<?php
$connect=mysql_connect("localhost","phptest","php");
$select=mysql_select_db("test",$connect);
/* create test table */
mysql_query("DROP TABLE IF EXISTS test_35183");
mysql_query("CREATE TABLE test_35183 (a varchar(20) character set
utf8)");
/* set client connection to utf8 */
mysql_query("SET NAMES utf8");
$expected = "四大皆空";
$query="insert into test1 values ('$expected')";
$result=mysql_query($query);
if (($result=mysql_query("select a from test_35183")))
{
$row=mysql_fetch_row($result);
printf("Expected: %s Returned: %s\n", $expected, $row[0]);
}
mysql_query("DROP TABLE test_35183");
mysql_free_result($result);
mysql_close();
?>
Output:
Expected: 四大皆空 Returned:
四大皆空
------------------------------------------------------------------------
[2005-11-12 02:42:52] lzx21cn at 21cn dot com
The problem maybe "Data truncation" When php write to mysql
but I do not know resolve it
------------------------------------------------------------------------
[2005-11-12 02:03:39] lzx21cn at 21cn dot com
do the same without PHP (using the console interface of MySQL in
gnome-terminal
-----------------------------------------------------------
drop table test1;
create table test1(id int,name char(4));
insert into test1 values(1,'ç大欢å');
insert into test1 values(2,'å大ç空');
select * from test1;
id | name
1 | ç大欢å
2 | å大ç空
-------------------------------------------
the reslut is good!
-------------------------------------------------
Why do I think it's a problem of PHP, not MySQL
1st. read/write by console vs. by php
by console: the result is right
by php : the result is wrong,write four Chinese character and read
only one chinese character back,and other character lost.
2nd. read Mysql by java vs. by php (creat record by console)
by java: the result is right
by php : the result is ? at field 'name'
--------------------------------------------------
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/35183
--
Edit this bug report at http://bugs.php.net/?id=35183&edit=1