0

Working with PHP and MySQL. When i save a string in the db, on retrieving it later on, it pulls out some funny characters instead of the double and single quotes in the original string. Some of those funny characters are †for the double quotes, ’ for the single quotes and – for the dashes. htmlspecialchars(), htmlentities and addslashes don't seem to solve my problem. Kindly help.

asprin
  • 9,579
  • 12
  • 66
  • 119
gthuo
  • 2,376
  • 5
  • 23
  • 30

2 Answers2

0

here i found utf8 tutoril which is help to solve prob.

example is give below

<form action="demo_form.asp" accept-charset="ISO-8859-1">
MageDev
  • 239
  • 2
  • 14
0

Call this:

header("Content-Type: text/html; charset=UTF-8");

It is also necessary to remove all the current misguided hacks (htmlspecialchars(), htmlentities , addslashes and especially accept-charset="ISO-8859-1") you have right now.

Recommended reading so that you understand why the above should work in your case:

After understanding this you should see the tell-tale signs of UTF-8 misinterpreted as Windows-1252 and Windows-1252 misinterpreted as UTF-8 from miles away.

To see that the header call is working correctly:

Esailija
  • 138,174
  • 23
  • 272
  • 326
  • @Esailijia, there is this HTML meta tag on that page: `` It serves the same purpose as the call above or? – gthuo Mar 29 '13 at 08:25
  • are you saying I should not use the functions above i.e. `htmlspecialchars, htmlentities` and `addslashes`? – gthuo Mar 29 '13 at 08:27
  • 1
    @GThuo yes, if you are using them (htmlentities, addslashes just makes no sense in general), then `charset=utf-8` has no effect. If you are using htmlentities, make sure you pass `UTF-8` as encoding. – Esailija Mar 29 '13 at 11:04
  • 1
    @GThuo No, the header has a priority. If your web server is currently sending a header with charset attribute, then the meta tag has no effect. Check the headers sent for your page. – Esailija Mar 29 '13 at 11:10