问题
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