MySQL, PHP and UTF-8
Posted by:
Bryan M.
Date: February 07, 2005 03:12AM
I'm having problems getting my data to display properly in PHP pages. I'm using MySQL 4.1.x and PHP 4.3.10. Because I do so much translation work, I've set everything to default to UTF-8 on the MySQL side, so all of my tables, fields, etc. are all encoded using UTF-8. I've even set Apache to use UTF-8 as the default when it's sending headers.
But when I try connecting to MySQL in PHP and then do a mysql_client_encoding, it always returns latin1. I've even tried using "SET NAMES 'utf8'" and "SET CHARACTER SET utf8", but I still get the same results when asking for the client encoding. How can I set it to use UTF-8 (other than using the mysqli functions because I didn't build that extension into PHP)?
Here's a little example of what I've done:
mysql_query("SET CHARACTER SET utf8", $conn);
mysql_query("SELECT * FROM products", $conn);
$charset = mysql_client_encoding($conn);
echo $charset;
This always displays "latin1". Thanks for the help.
Subject
Views
Written By
Posted
MySQL, PHP and UTF-8
3125
February 07, 2005 03:12AM
2323
May 07, 2005 08:57AM
1873
July 26, 2005 07:59AM
1891
March 13, 2006 07:55PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.