The Euro symbol triggers the mysql insert process

I have written data crawling engine which does (so far) everything right except it completely stops data inserting process at the point where euro € symbol ocurres in the text. I belive this symbol may not be the only one.

If string that is about to be inserted into database table looked like this:

Quick brown € fox jumped over the laizy dog.

this would end up in database:

Quick brown

My trouble is that I’ve followed several instructions found on this site about precisely this issue
, with no luck.

What I have already done to fix this(php-side):

made sure that:

mysqli_set_charset($dblink, "utf8");
mysqli_real_escape_string($dblink, $string);

tried with:

iconv('windows-1250','utf8//TRANSLIT', $string );
iconv('windows-1250','utf8', $string );/*crawled web page declared windows-1250 characterset*/

(here I had success finishing data insertion with € symbol preserved, however other latin characters čćšđž was completely degraded)

  • several others attempts with mb_convert_encoding()
  • attempts to change server response with of Accept
    and Accept-Charset

mysql side:

Table and fields was set to utf8_unicode_ci

to utf8 (did that to existing, non-empty database)

No success. Whatever I attempt to, insertion process stops with € symbol.

Does anyone know what should I do?

I’ve tested these on my php/mysql install, and both work. Note, I couldn’t get euro to work on my command line since my character encoding didn’t support it, so I selected it out of a DB first which worked perfectly.

$original = 'Quick brown '.$euro.' fox jumped over the laizy dog.';
$escaped =  str_replace($euro,'\'.$euro,$original);
echo $escaped;
$database->insertSQL('insert into test (text) values (''.$original.'')');
$database->insertSQL('insert into test (text) values (''.$escaped.'')');

Both the original and escaped insert correctly into my DB, and the escaped doesn’t have the backslash since SQL knows how to handle it.

The only thing I can think might be incorrect with your DB, is the encoding. My encoding is latin1_swedish_ci. If you change the encoding on your table, does my code block above help?

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 后端存储 » The Euro symbol triggers the mysql insert process

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录