How to enable UTF-8 and Latin Charatersets in PHP and MySQL

I can view the UT8 characters correctly in phpMyAdmin. The data is stored correctly in the MySQL db.

However, when I call the data on a php page, php displays a? instead of the characters from the db.

This solved it for me.

mysql_query(SET NAMES utf8);
after mysql connection.


or Try this

<!-- xml version="1.0" encoding="UTF-8" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>
<?php echo $utf8variable;?>
<body>
<html>

Handing Character Encoding in PHP Applications


Subject