CakePHP / Mysql Insert UTF-8

半腔热情 提交于 2019-12-11 02:48:24

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7662093/cakephp-mysql-insert-utf-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!