开发者

Mysql or PHP not converting quotes correctly

I have a textarea where users enter some information. Some users enter single and double quotes in their information and what i end up seeing in the开发者_运维技巧 page is â�� and all types of weird characters where single/double quotes are suppose to be. I simply use the function mysqli_real_escape_string() and trim() to store the information and htmleneties() to display them in php.

I my database I already see the � characters so why the single/double quotes are property stored? Thanks!


Inconsistent character sets. Make sure the same character set is used on the database, the database connection, the database table, the table column, the content-type header used when serving the page, and the content-type meta tag of the page. You also want to avoid using PHP string functions on multibyte encodings as they're only safe for iso-8859-1 encoded text. If you plan to accept and display languages other than English you should probably be using UTF-8.


  • Be sure you have utf8 encoding in DB
  • Be sure you set names

mysql_query("SET NAMES utf8");

  • be sure you set charset in php

header("Content-type: text/html;charset: utf-8");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜