Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP mysql charset utf8 problems [duplicate]

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: '

like image 979
Samuele Avatar asked Dec 28 '12 11:12

Samuele


1 Answers

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);
?>
like image 199
Codesen Avatar answered Sep 21 '22 20:09

Codesen