Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UTF-8 Characters into MySQL using PHP

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
I am using the following
PHP 5 and Mysql 4

I have a PHP form that I want to enter UTF-8 characters into a MySQL database.
The top of the php form has

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

I know the MySQL database holds the characters properly as I can paste the characters directly into the Database using a GUI tool.

When I enter the Characters through the PHP form, it looks like the following in the database.

&#21442;&#29031;&#30058;&#21495;

Can anyone advise me how to get these characters to enter correctly.

 
Just thought I'd let people know how I solved the problem.

First of all I had to add the following line into my code.

mysqli_query($db, "SET CHARACTER SET utf8");
where $db is my connection string.

I then saved the file with the file encoding set to UTF8 using Microsoft Notepad on Win 2000 Pro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top