mysql不能存字母,使用不常見的字母/符號時,MySql數據庫不能正確存儲數據
I have a simple form that sends (via php) some variables to a mySql database.
我有一個(gè)簡單的表單,通過PHP發(fā)送一些變量到mySql數(shù)據(jù)庫。
The problem is that it's focused to Portuguese audience, and we use several unusual letters, like "?" and "?". Whenever someone sends data with those letters, the result is very "garbled" in the phpMyAdmin.
問題是它專注於葡萄牙觀眾,我們使用幾個(gè)不尋常的字母,如“?”和“?”。每當(dāng)有人用這些字母發(fā)送數(shù)據(jù)時(shí),phpMyAdmin中的結(jié)果都非常“亂碼”。
Quick example for a field would be "Escola de Condu??o Clássica" apears as "4573636f6c6120646520636f6e6475c383c2a7c383c2a36f20436c617373696361" in the phpMyAdmin.
一個(gè)字段的快速示例是“EscoladeTrans??oClássica”,在phpMyAdmin中為“4573636f6c6120646520636f6e6475c383c2a7c383c2a36f20436c617373696361”。
I tried setting the collation to "utf8_bin", with no avail.
我嘗試將排序規(guī)則設(shè)置為“utf8_bin”,但沒有用。
Any ideias?
Thank you.
EDIT: Field type is varchar(30) and charset shows as "utf8".
編輯:字段類型是varchar(30),字符集顯示為“utf8”。
2 個(gè)解決方案
#1
0
ALTER TABLE mytable CONVERT TO CHARACTER SET utf8
ALTER TABLE mytable CONVERT TO CHARACTER SET utf8
#2
0
I found out the problem. Turns out I just needed to call my hosting to change the php setting. I wish I had tried this beforehand, but I though it was something wrong on my end. Also, it makes no sense for them to have another encoding other than UTF-8, considering its a Portugal (european) based hosting.
我發(fā)現(xiàn)了問題。事實(shí)證明我只需要調(diào)用我的主機(jī)來更改php設(shè)置。我希望我事先嘗試過這個(gè),但是我覺得這樣做有些不對勁。此外,考慮到它的葡萄牙(歐洲)主機(jī),它們沒有其他編碼而不是UTF-8。
Anyway, if someone gets this error, try asking the hosting about which encoding is used in the php setting (it should have been UTF-8 in my case, might be diferent for you).
無論如何,如果有人收到此錯(cuò)誤,請嘗試詢問托管在php設(shè)置中使用了哪種編碼(在我的情況下應(yīng)該是UTF-8,對您來說可能不同)。
And yes, this problem took a while because I eventually ignored it, but I had to do something similar recently in a diferent site (using the same hosting).
是的,這個(gè)問題需要一段時(shí)間,因?yàn)槲易罱K忽略了它,但最近我不得不在不同的網(wǎng)站(使用相同的托管)做類似的事情。
總結(jié)
以上是生活随笔為你收集整理的mysql不能存字母,使用不常見的字母/符號時,MySql數據庫不能正確存儲數據的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nvsvc.exe - nvsvc是什么
- 下一篇: 小米徕卡旗舰即将发布 官网大改版:细节你