0

I'm writing an html5 web page to store input from users in a MySQL database. The web page has tags <html lang="en">, <meta charset="utf-8"> and <form ... accept-charset="utf-8">.

I'm using PHP 5.4 and MariaDB 5.5.44. The database's character's set to UTF8. The table's character's set to UTF8. Collation is set to utf8_general_ci.

Why am I getting weird characters in my database? E.g. when I upload "á" it becomes "á"?

I'm pretty much a noob at coding and the docs go above my skill level.

user281681
  • 315
  • 1
  • 7
  • hey Mark, thanks for pointing that out. I had been looking through articles for over an hour and this one didn't pop up in the results (or it got drowned in all the other charset/collation/utf8 entries). Seems like a decent article, definitely going to bookmark it! :) – user281681 Dec 14 '15 at 01:45

1 Answers1

1

Try this: Directly after the DB connection initialisation, insert

$mydb->set_charset("utf8");

(where $mydb is the variable for your db connection) In my case this helped in a similar situation.

Johannes
  • 64,305
  • 18
  • 73
  • 130
  • Oh man, you're the best :) I'm using PDO, so the statement's syntax is a little different but indeed I forgot to put the charset to utf8 in the db connection. – user281681 Dec 14 '15 at 00:29