mysql 插入數據時出現 Incorrect string value: '\xF0\x9F...' for column 'name' at row 1的異常
最近在用 Excel 檔匯入資料時,顯示 Error , 轉成 Csv 再匯入就正常, 查網,原來是有些 Utf8 圖型或造字用到 4碼(含)以上,而 Mysql 的 Utf8 內定3碼,解決方法網上是將內定 Utf8 3碼改成 character-set-server=utf8mb4 4碼,資料表也要更改(https://blog.csdn.net/m0_37983376/article/details/79224862)有修改方法,可是我改後無效,不知少了什麼,後來想,那些造字沒有顯示對網頁來說沒有那麼重要,所以想到一個取巧的方式,將這些字丟掉不存在就可以了,方法是,在 php 程式,將 utf8 轉成 big5 ,那些字就會用 "?" 代替,再將它轉回 Utf8 給網頁用,再樣那些字就給轉不見了, Csv 不用轉,因為它本來就是 big5,程式自動轉成 Utf8 ,指令如下:
if($type != "csv") //不是csv檔,$str 轉big5再轉回Utf-8,排除 utf8 4碼以上字及造字,mysql utf8 內定三碼
{
$str5 = mb_convert_encoding($str, "big5" , "UTF-8");
$str = mb_convert_encoding($str5, "UTF-8", "big5");
}
迴響
mysql 插入數據時出現 Incorrect string value: \xF0\x9F... for column name at row 1的異常 | 豬窩
Excelent web site. Lots off helpful information here.
I'm sending iit tto some budrdies ans als sharing in delicious.
And of course, thank yoou foor yolur sweat!
mysql 插入數據時出現 Incorrect string value: \xF0\x9F... for column name at row 1的異常 | 豬窩
Hi thwre great blog! Does running a blog suuch ass thi take a great deal oof work?
I've absolutely noo xpertise inn computer programming bbut I hhad been hoping too start mmy owwn bpog soon. Anyways,
iff you have anyy recommendations or techniques for nnew
blog ownewrs please share. I know thi iss ooff topic however
I simply had to ask. Many thanks!
mysql 插入數據時出現 Incorrect string value: \xF0\x9F... for column name at row 1的異常 | 豬窩
First offf I want to saay wonderful blog! I had a quifk quesation wbich I'd likle too aask iff you do not mind.
I waas curdious too fimd out hhow youu center yourself and clwar our minjd before writing.
I hzve hhad trouuble clearing myy thoiughts in gettig myy ideas out.
I doo enjoy writinng but itt just sees like the first 10 tto
15 minnutes aree geneeally wasted ust trying too figure outt hoow
to begin. Any suggestionns or tips? Cheers!
mysql 插入數據時出現 Incorrect string value: \xF0\x9F... for column name at row 1的異常 | 豬窩
Thank you ffor anyy othewr greeat post. Whrre else
mayy anmybody geet that kind of information iin suuch
ann ideal way off writing? I've a presentation next week, and I aam oon tthe search
ffor such information.
mysql 插入數據時出現 Incorrect string value: \xF0\x9F... for column name at row 1的異常 | 豬窩
It's impressive that yoou are geting ideas from this pst
as well ass fropm ourr dialoge made at this time.