14

Possible Duplicate:
UTF-8 all the way through

I'm developing some new features on a website that somebody else already developed.

I'm having a problem the charset.

I saw that the database had some tables in utf8 and some in latin1

So I'm trying to convert all the tables in UTF8.

I did it for one table (also the fields of this table now are utf8), but was not successful.

I'm using the normal mysql connect. I have to put any config to say that it must connect with utf8 to the DB? If yes witch one?

In my html I have:

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

It looks like some letters works and others display the question mark. For example it not able to display this ’ that is different of this: '

Community
  • 1
  • 1
Samuele
  • 512
  • 1
  • 9
  • 23
  • Which characters are displaying as question mark in DB? – Farid Movsumov Dec 28 '12 at 11:14
  • don't get crazy. So check your question again, edit it and actually ask a question. *"It looks like some letters works and others display the question mark."* - such sentences are just not helpful. I bet for you they are not helpful as well. – hakre Dec 28 '12 at 11:14
  • Also contact the person you got the code from for documentation. Also search for your question. E.g. the part about mysql character configuration has been asked and answered about before - you don't need to ask again, you can just search. E.g. [Whether to use “SET NAMES”](http://stackoverflow.com/q/1650591/367456) and [SET NAMES utf8 in MySQL?](http://stackoverflow.com/q/2159434/367456). – hakre Dec 28 '12 at 11:14
  • 4
    Maybe `mysql_query('SET NAMES UTF8;');` is useful to you. It helped me with some PHP/MySQL + UTF-8 related issues in the past. I don't know your exact issue so it might not be what you want. – Patrickdev Dec 28 '12 at 11:16

1 Answers1

35

Try this

<?php

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

and then in the connection

<?php
 $dbLink = mysql_connect($argHost, $argUsername, $argPassword);
    mysql_query("SET character_set_results=utf8", $dbLink);
    mb_language('uni'); 
    mb_internal_encoding('UTF-8');
    mysql_select_db($argDB, $dbLink);
    mysql_query("set names 'utf8'",$dbLink);
?>
Codesen
  • 7,724
  • 5
  • 29
  • 31
  • I did that and I also had to remove all the htmlentities() and utf8_encode() functions that was used. Thanks – Samuele Dec 30 '12 at 00:36