Low Search error 1366 when indexing.
I have a utf 8 database and I am getting this error when I try to update entries or try to update the index on a collection:
Error Number: 1366
Incorrect string value: '\xC2 full...' for column 'index_text' at row 1
REPLACE INTO 'exp_low_search_indexes' ('collection_id', 'entry_id', 'site_id', 'index_text', 'index_date') VALUES ('4', '4441', '1', '| order supplies | order supplies |\n| select the supplies you d like to order with and submit your contact information a representative will contact you shortly to finalize your order order supplies  full name first last company institution email phone state province category 1 supplies pre paid air bill item item item item other category 2 supplies pre paid air bill item item item item other category 3 supplies pre paid air bill item item item item other question comment do not fill this out |', 1352239516)
Filename: W:\Websites\.......\system\codeigniter\system\database\DB_driver.php
Line Number: 330
I am not sure how or why I have this character in the string but it stops me from indexing the entry. To fix this I added this around line 200 of low_search_helper.php
$str = preg_replace('/[^(\x20-\x7F)]*/','', $str);
I would like to know if this issue is coming from something I am doing but I am mostly posting this here in case someone else has this issue.
Replies
Low 6 Nov 2012 22:16
Hi! Can you post the actual text of the entry #4441? I reckon there might be some kind of special character there that's being encoded incorrectly somehow.
Cymbal 6 Nov 2012 22:39
Yeah, that regex didn't fix it.
For some reason it is choking on
characters that get converted into \xC2.If I try to submit this I get a failure:
Save favorites to your account? Log in »
Low 6 Nov 2012 22:43
I think I might have to take a look myself. Can you send SuperAdmin login credentials to hi at gotolow dot com?
Cymbal 6 Nov 2012 22:48
Yeah, I ended up fixing it using this:
$str = preg_replace('/(\xC2\xA0| )/', ' ',$str);
I am not sure if I needed this simply because of my environment or what but I am using WAMP with MySQL in UTF-8. It is coming from a Wygwam field so that may also have to do with it.
Low 6 Nov 2012 22:55
Hmm, but it shouldn't be necessary... What version of Low Search are you on?
Cymbal 6 Nov 2012 23:01
I'm on 2.0.1
Would updating fix the issue?
Thanks for the quick responses by the way.
Low 6 Nov 2012 23:04
Oh yes, updating would definitely solve it. See the changelog: http://gotolow.com/addons/low-search/...
In version 2.0.4, non-breaking spaces were dealt with.
Cymbal 6 Nov 2012 23:12
Thanks, that definitely solves my issue.