0

Possible Duplicate:
UTF-8 all the way through

I'm trying to insert special characters (like é etc.) in a MySQL database but when I insert through a query, in the database it appears as: "é". When I insert the query directly in Phpmyadmin, it works as it should. I have already set the collection charset to utf8_unicode_ci. I have this in my HTML:

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

How can I fix this? (I already googled it, but I only found the collection things, that won't work..)

(jQuery because I'm sending it with a $.POST)

Community
  • 1
  • 1
Wouter0100
  • 430
  • 6
  • 19

3 Answers3

1

Is your database connection using utf8?

Try running this sql when you initialise your db connection:

SET NAMES 'utf8';

I suggest you read through this too.

WayneC
  • 5,569
  • 2
  • 32
  • 43
1

Make sure the connection to your database is also using this character set:

$conn = mysql_connect($server, $username, $password);
mysql_set_charset("UTF8", $conn);

see this answer: answer

Community
  • 1
  • 1
yanddam
  • 399
  • 2
  • 12
0

Try to do

mysqli_query('SET NAMES utf8');

after connecting to database.
According to the manual, SET NAMES indicates what character set the client will use to send SQL statements to the server. Thus, SET NAMES 'utf8' tells the server that future incoming messages from client will be in utf8 encoding. It also specifies the character set that the server should use for sending results back to the client.

bhovhannes
  • 5,511
  • 2
  • 27
  • 37