CakePHP / Mysql插入UTF-8 [英] CakePHP / Mysql Insert UTF-8
问题描述
都很好吗?
所以,是以下内容:
CakePHP 1.3.11
MySQL 5.1
Apache 2.2
PHP 5.3
Charset /整理为应用程序创建的数据库:
utf8
utf8_general_ci
app / config / database.php
'encoding'=> 'utf8'
所有文件的字符集:
utf8
当我尝试保存时,例如:
Currículo
我收到了
CurrÃculo
问题在哪里?
:本地在我的笔记本上,应用程序工作正常,甚至保存不正确,即,即使保存CurrículoCakePHP当银行采取数据时,他们被正确呈现,但是当传递到客户端服务器,以相同的方式出现
解决方案这是非常奇怪的。 maybeeeee ..(我假设
Currículo
来自HTML FORM)
检查您使用head标记上的正确字符集:
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
如果您使用的是Firefox,请转至View-> Encoding以检查是否选择了utf-8 。 (元应该告诉firefox应该使用什么字符集)
如果这不是问题,尝试做一个简单的查询测试,例如:
$ this-> MyModel-> query(INSERT INTO ....('Currículo'));
如果它不工作,那么你会知道问题是php和mysql之间。
希望这有助。
all are well?
So, is the following:
CakePHP 1.3.11 MySQL 5.1 Apache 2.2 PHP 5.3
Charset / Collate the database created for the application:
utf8 utf8_general_ci
app / config / database.php
'encoding' => 'utf8'
charset of all files:
utf8
The problem? When I try to save, for example:
"Currículo"
I got in return
"CurrÃculo"
Where is the problem?
Note: locally on my notebook, the application works correctly, even saving incorrectly, that is, even saving "Currículo" CakePHP when the bank takes the data, they are presented correctly, BUT when passing it to the client server, appeared in the same way in the database.
It really is very strange.
解决方案maybeeeee.. ( i'll assume that
Currículo
comes from an HTML FORM )check that you're using the correct charset on the head tag:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
if you're using Firefox, go to View->Encoding to check that utf-8 is selected. (the meta should tell firefox what charset should be used)
If that's not the problem, try doing a simple query test, something like:
$this->MyModel->query("INSERT INTO .... ('Currículo')");
if it doesn't work, then you'll know that the problem is between php and mysql.
Hope this helps.
这篇关于CakePHP / Mysql插入UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!