views:

32

answers:

1

In my database in some fields the data is showing like as in following screenshots:

  1. http://i31.tinypic.com/2637l9f.jpg
  2. http://i27.tinypic.com/1ihh6d.jpg
  3. http://i26.tinypic.com/2yklzb4.jpg
  4. http://i31.tinypic.com/2vbshtf.jpg

I used mysql_real_escape_string while inserting my data into database and htmlspecialchars while displaying.

Can any one tell me why they looking like this, and whats the solution?

+2  A: 

That's Mojibake. Your PHP and MySQL code are not ready for World Domination.

To fix it properly, go through this cheatsheet and ensure that every layer is using UTF-8.


The mysql_real_escape_string() basically only prevents you from SQL injection attacks and the htmlspecialchars() basically only prevents you from XSS attacks. They do not assist in encoding or decoding the characters in any way. The character set used is responsible for that. Your problem is that you're not consistent in using the charset and/or that the charset you've chosen/used does not support the characters which the client entered and/or you'd like to use.

BalusC