Hello, I am having a weird problem trying to work with a trademark symbol stored in a database.

It is being put into a text field and I want it to be stored in the database as = ™

I tried this:

str_replace('™', '™', $str )

but it doesn't work, any other ideas?

Thanks so much in advance.

    I have been trying to find this solution for over 2 days! And of course after I post something here I find a soltution, anyways I thought I would share it.

    I needed to use:

    htmlentities($str, ENT_QUOTES, 'utf-8')

      ... but why convert it at all? Why not just save it as ™? Switching to the entity reference (aside from being completely unnecessary with utf-8) only creates more opportunities for mistakes later on.

        I am storing the information in a database, and when I display it I need it to be ™ otherwise when it displays in the website its a blank triangle with a question mark.

          creativeink;11006122 wrote:

          I am storing the information in a database, and when I display it I need it to be ™ otherwise when it displays in the website its a blank triangle with a question mark.

          Your webpage's character encoding probably isn't UTF-8 then. I would double-check that.

            And if that is UTF-8, then check that the character encoding used by the database is UTF-8 as well. And while you're at it, check what your editor is using, too.

              yup... ditto. You really don't need to use the entity. It's a symptom of a bigger problem (mismatched character encoding(s), somewhere along the line). Check your page's meta tags, as well as your server's http headers.

                Wow thanks a lot for the help guys this is great.

                My Meta tag is:

                <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

                I am using the Ckeditor - http://ckeditor.com/

                Does it use UTF-8??

                  IF your webpage is using utf-8, then yes. However, you need to check what HTTP headers your server is sending. Generally, a browser will ignore your meta tag if it conflicts with what the server says the charset is.

                    And when I say "editor", I mean whatever you're using to edit your PHP code.

                      Write a Reply...