yes, when i post a problem, someone told me to give more info
when i post the whole php-script, no response
mysql-4.x unable to handle binary data when using multibyte charset, (maybe
the old mysql-3.x escape/unescape is fine)
file: mysql-4.0.1-alpha/libmysql_r/libmysql.c
in function mysql_sub_escape_string
...
#ifdef USE_MB
int l;
if (use_mb_flag && (l = my_ismbchar(charset_info, from, end)))
{
while (l--)
*to++ = *from++;
from--;
continue;
}
#endif
what the hell is that "while (l--) *to++ = *from++;" ??
it has never been in old mysql-3.x
::::::::::::and now, re-post my mail here::::::::::::
ok, finally have a kind man take a look at my problem :)
now before pasting a long example-script
here is the test result:
**********************************************
case 1
php4.2, mysql4.0.2 using GBK charset, windows
mysqlclient-gbk is not supported by php4.2 win build, but i made gbk.conf
in C:\mysql\share\charsets
result:
========
string -> ? ( [ ?] [ " ] )
escaped -> �\" ( [ ?] [ \ ] [ " ] )
result -> �\" ( [ ?] [ \ ] [ " ] )
*** damn!
========
string -> ? ( [ ?] [ ' ] )
escaped -> �\' ( [ ?] [ \ ] [ ' ] )
cant query, error:#1064 You have an error in your SQL syntax near ''�\'''
at line 1
========
string -> �\' ( [ ?] [ \ ] [ ' ] )
escaped -> �\\\' ( [ ?] [ \ ] [ \ ] [ \ ] [ ' ] )
cant query, error:#1064 You have an error in your SQL syntax near ''�\\\'''
at line 1
**********************************************
case 2
php4.2, mysql4.0.2 using GBK charset, linux
php4.2 compiled with lib mysql, GBK supported
result:
========
string -> ? ( [ ?] [ " ] )
escaped -> �\" ( [ ?] [ \ ] [ " ] )
result -> �\" ( [ ?] [ \ ] [ " ] )
*** damn!
========
string -> ? ( [ ?] [ ' ] )
escaped -> �\' ( [ ?] [ \ ] [ ' ] )
cant query, error:#1064 You have an error in your SQL syntax near ''�\'''
at line 1
========
string -> �\' ( [ ?] [ \ ] [ ' ] )
escaped -> �\\' ( [ ?] [ \ ] [ \ ] [ ' ] )
result -> �\' ( [ ?] [ \ ] [ ' ] )
* fine
and the php test script
**************************
<?php
error_reporting(E_ALL);
$conn = mysql_connect('localhost', 'user', 'pass') or die('cant connect');
test(chr(200) . '"', $conn);
test(chr(200) . "'", $conn);
test(chr(200) . "\\'", $conn);
function test($str, &$conn)
{
echo "<br>========<br>";
dump_str('string', $str);
$q_str = mysql_escape_string($str); // you may also try
mysql_escape_string() (php cvs only)
dump_str('escaped', $q_str);
$res = mysql_query("SELECT '$q_str'");
if (!$res) {
print('<font color=red>cant query</font>, error:#'
. mysql_errno()
. ' '
. mysql_error());
return;
}
$row = mysql_fetch_row($res) or die('empty result');
dump_str('result', $row[0]);
echo $row[0] === $str ? "* fine<br>":"*** damn!<br>";
}
function dump_str($name, $str)
{
echo "$name -> $str (";
for ($i = 0; $i < strlen($str); $i ++)
{
echo ' [ ' , $str{$i}, ' ] ';
}
echo ")<br>";
}
?>
>From: Paul DuBois <[EMAIL PROTECTED]>
>To: "xuefer tinys" <[EMAIL PROTECTED]>,
[EMAIL PROTECTED],[EMAIL PROTECTED]
>CC: [EMAIL PROTECTED]
>Subject: Re: Japanese Charset
>Date: Fri, 20 Sep 2002 08:56:22 -0500
>
>At 9:09 +0000 9/20/02, xuefer tinys wrote:
>>i'm sure mysql4.x have wrong algorithm to escape/unescape multibyte
>>chars
>>a multibyte is escaped while server read it, it maybe a pair of
>>single byte
>>or a pair of single byte escaped while server read it, it appears
>>as multibyte
>>both of these two situation make server unescape incorrectly
>>i've post the problem, no one take attention to it. at least, those
>>who not using multibyte will never care about this problem.
>
>You'll probably find that the issue receives more developer
>attention
>if you can provide hard evidence that there is a problem, preferably
>accompanied by a repeatable test case. The assertion "I'm sure
>MySQL
>has a problem" just doesn't carry much weight otherwise. There are
>plenty
>of assertions like that on this mailing list, the vast majority of
>which turn
>out to be misunderstanding on the user end.
>
>I'm not saying you haven't uncovered a real bug, just that a better
>demonstration that there *is* a bug would be more helpful than just
>making
>a claim.
>
>>
>>dunno weather your problem really cause by this wrong
>>multi-byte-escape-algorithm
>>
>>>From: Joel Rees <[EMAIL PROTECTED]>
>>>To: "Dawn Friedland" <[EMAIL PROTECTED]>
>>>CC: [EMAIL PROTECTED]
>>>Subject: Re: Japanese Charset
>>>Date: Fri, 20 Sep 2002 16:25:29 +0900
>>>
>>>...
>>>
>>>> The problem characters are the ASCII backslash and the ASCII
>>>>tilde -
>>> > Good to know, I will eliminate those, although there are still
>>>many
>>more
>>> > problem characters.
>>>
>>>Well, actually, the one-byte backslash and tilde you can leave
>>>alone.
>>>They survive intact, they just display differently over here.
>>>Everybody's used to it, so no problem. Even programming in C, when
>>>we
>>>write something like '\t', the backslash (0x5c) shows up in our
>>>editors
>>>as the yen symbol, and we pretend that the escape character is the
>>>yen
>>>symbol, because, for us, when the encoding is shift-JIS, it is. So
>>>don't
>>>worry about the one-byte characters.
>>>
>>>...
>>>
>>>I checked the text you gave me, and I found what's getting
>>>clobbered.
>>>It's the latter half of characters like the katakana 'so'.
>>>
>>>Although the byte that is getting walked on here is 0x5c, this is
>>>_not_
>>>the escape character. It is preceded (in the case of katakana
>>>'so') by a
>>>byte of 0x83. The entire character is '0x835c', and the 0x5c is
>>>being
>>>treated as if it were a backslash. There are other characters that
>>>will
>>>get hit by this, by the way.
>>>
>>>Bells ringing all over in my head. I think your content tool is
>>>mishandling backslashes, but it could be that MySQL or the driver
>>>is
>>>doing something the tool doesn't expect. (Well, really, the tool
>>>is
>>>probably mis-handling the backslashes.)
>>>
>>>This is actually independent of the language issues. I'm pretty
>>>sure
>>>I've seen this subject come up before on the list, just can't
>>>remember
>>>which way the turkey rolled. But your content tool will need to do
>>>something slightly different with the input.
>>>
>>>Could you search the archives about escape sequences or the
>>>backslash
>>>character?
>>>
>>>(Maybe someone who remembers could chime in here?)
>>>
>>>--
>>>Joel Rees <[EMAIL PROTECTED]>
>>>
>>>
>>>---------------------------------------------------------------------
>>>Before posting, please check:
>>> http://www.mysql.com/manual.php (the manual)
>>> http://lists.mysql.com/ (the list archive)
>>>
>>>To request this thread, e-mail
>>><[EMAIL PROTECTED]>
>>>To unsubscribe, e-mail
>><[EMAIL PROTECTED]>
>>>Trouble unsubscribing? Try:
>>>http://lists.mysql.com/php/unsubscribe.php
>>
>>
>>
>>
>>_________________________________________________________________
>>�^����I��F���s���C���g�p MSN Messenger:
>>http://messenger.microsoft.com/cn
>>
>>
>>---------------------------------------------------------------------
>>Before posting, please check:
>> http://www.mysql.com/manual.php (the manual)
>> http://lists.mysql.com/ (the list archive)
>>
>>To request this thread, e-mail <[EMAIL PROTECTED]>
>>To unsubscribe, e-mail
>><[EMAIL PROTECTED]>
>>Trouble unsubscribing? Try:
>>http://lists.mysql.com/php/unsubscribe.php
_________________________________________________________________
�����������ѽ��н�������ʹ�� MSN Messenger:
http://messenger.microsoft.com/cn/
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php