CakePHP / Mysql插入UTF-8 [英] CakePHP / Mysql Insert UTF-8

查看:204
本文介绍了CakePHP / Mysql插入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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆