1

Having some issues inserting data into my UTF-8 database. The main issues I'm having is with words containing ��!.

The code I'm using so far is

        $enc = mb_detect_encoding($content);
        $data = mb_convert_encoding($content, "ASCII", $enc);

But no luck so far. Does that mean it can't detect the encoding? or something else?

SnIpY
  • 662
  • 2
  • 10
  • 27

1 Answers1

0

You are converting to ASCII. ASCII probably doesn't have the characters you need, and why would you convert to ASCII if your database supports UTF8? why not:

$enc = mb_detect_encoding($content);
$data = mb_convert_encoding($content, "UTF-8", $enc);
Garr Godfrey
  • 8,257
  • 2
  • 25
  • 23
  • Even better, why convert at all? Have your web page be UTF-8, and your database be UTF-8, and never have any strings that aren't UTF-8. Presto, no conversions needed. – Amadan Sep 10 '14 at 03:51
  • i agree. I don't know where this "$content" is coming from. – Garr Godfrey Sep 10 '14 at 03:51