开发者

How to get correct character-encoding between mysql and filemaker

I'm unsure if this is a php-, filemaker-, mysql- or an odbc driver issue.

For security reasons the input fields of my current php webform convert special characters into hex codes, (for example: # becomes ' ) 开发者_运维百科This hex code is saved in the database and will also be shown in Filemaker11 as the hex code. This is not what i want. How can I make sure the special character will be displayed as it should be?

The other way round (from filemaker to db), no conversion will be done on inserting the special characters.

How can I make sure everything will be consistent?

Kind regards, Jeroen


FileMaker is just showing the data stored in MySQL. If you pull up the DB in a tool like PhpMyAdmin you should see that the varchar contains the encoding as well. Since FMP is looking at it simply as a text field, it shows the encoding that was stored. If you wanted to decode in FMP you could show a calc field of the varchar that has a custom function to decode the text. (but that won't allow for updating the data..) You could also try a trigger on record load to decode the data in the fields so that you can properly view/edit.


Solved it! It appeared that I had to add an extra line to my PHP script.

after setting up the connection, php needs to tell mysql what the encoding needs to be. This can be done with the following line:

$dbh->query("SET NAMES 'utf8'");

Thanks for the effort guys!


This: ' type of encoding is not done automatically by the browser. Something is doing it. Normally you do it only on output not on input.

You can use html_entity_decode() to undo it. But I strongly suggest you figure out why it's happening in the first place.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜