FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Cannot write utf8 data into a utf8 column
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Cannot write utf8 data into a utf8 column - SOLVED [message #170752 is a reply to message #170747] Fri, 19 November 2010 16:25 Go to previous messageGo to previous message
Tony Marston is currently offline  Tony Marston
Messages: 57
Registered: November 2010
Karma:
Member
"Peter H. Coffin" <hellsop(at)ninehells(dot)com> wrote in message
news:slrniebqgp(dot)1g0(dot)hellsop(at)abyss(dot)ninehells(dot)com...
> ["Followup-To:" header set to comp.databases.mysql.]
> On Thu, 18 Nov 2010 16:54:47 -0000, Tony Marston wrote:
>> This is very strange. When I try this update in my PHP program:
>>
>> UPDATE email_msg
>> SET size=771,
>> message_text='? ?:\n\n ????2010?11?25-26? ? ? ? 12?09-10? ? ?
>> ?12?16-17?
>> ?? ????:\n\n?
>> ????2010???????2011?????????????????????????
>> ????!\n\n?????????????????????????????????????????--?
>> ? ?? ??!\n\n\n????????????:baoming_gz(at)126(dot)com??! ( ?????????!)??!
>> \n\n\n\n?-?-?-?:0-2-0--3-9-9-2-6-2-7-5?(0)1-3-7-1-9-0-2-5-4-7-6
>> ???
>> ????\n\n?-?-?-?:baoming_gz(at)126(dot)com\n\n\n????????,?????"??"?"delete"?:tuidin01(at)163(dot)com
>> ??!',
>> revised_date='2010-11-18 15:48:09',
>> revised_user='AJM'
>> WHERE email_id='159'
>>
>> it fails with the following error:
>>
>> "Incorrect string value: '\xA0\xA0 \xE6\x88\x91...' for column
>> 'message_text' at row 1"
>>
>> When I try the SAME update through SQL-Front or phpMyAdmin it works! Why
>> is
>> this?
>
> If it were the SAME, it would work the same. MySQL gives this error when
> there's invalid UTF-8 byte sequences, like a continuation byte without
> starting byte, or a starting byte that is not followed by a continuation
> byte... Find out what the hex for what you're trying to stick in
> message_text and I bet it won't be what it should be.

The error message was reporting a problem with the hex value \xA0 (decimal
160) which represents '&nbsp;' or the non-breaking space. I discovered that
instead of replacing '&nbsp;' with chr(160) that I needed to replace it with
chr(194).chr(160). I don't now why the chr(194) is necessary, but it solves
my problem.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: store backslash in mysql database
Next Topic: Firewall - NetDefender :
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 14:44:59 GMT 2024

Total time taken to generate the page: 0.05326 seconds