-1

I'm creating a messaging system with PHP and MySQL but am having problems when certain characters are entered. Particularly the Pound sign (£).

The form where users write their message is POSTed to a PHP script with the following functions:

$message = htmlspecialchars($message, ENT_QUOTES);
$message = utf8_encode($message);

Then $message is INSERTed into a Database where it is stored in a Text Column.

However, when inputing a Pound sign no data appears in the database at all on my live server, but on my localhost (using MAMP) £ appears in the database.

Anybody know whats going on? And is there a way to encode £ as £, I feel like that might solve my issue.

Splycd
  • 161
  • 2
  • 3
  • 15
  • [What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text](http://kunststube.net/encoding/), [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/) – deceze Jan 30 '17 at 12:02
  • You have Mojibake. See this for causes and fixes: http://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Jan 30 '17 at 23:31

1 Answers1

1

If your database encoding is not UTF-8, or if the application does not retrieve data from the database as UTF-8, data stored in the database will not render correctly.Check your db encoding please and if this is not the problem put this to your php page

header('Content-Type: text/html; charset=utf-8');