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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UTF-8 not displaying correctly 1

Status
Not open for further replies.

PeDa

Technical User
Oct 10, 2002
227
0
0
NL
My MySQL table contains correct UTF-8 data, However when I read this into PHP it is not correctly displayed

Code:
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel=StyleSheet href="misc/pdavis.css" type="text/css">
<TITLE>Test UTF-8</title>
</head>
<body>
<?php
$db=mysql_connect("localhost", "XXXXXX", "XXXXXXXXXXX");
mysql_select_db("XXXXXX",$db);
  $Temp="SELECT * FROM tbTest";
  $result=mysql_query($Temp,$db);
  while ($myrow = mysql_fetch_array($result))
    {
    echo  $myrow["Text"] . "</br>" ;
    }
?>
</body>
</html>

My .htaccess contains (only): AddDefaultCharset utf-8
 
Code:
$db=mysql_connect("localhost", "XXXXXX", "XXXXXXXXXXX");
mysql_select_db("XXXXXX",$db);
mysql_query('set names "utf8"');

this assumes that the data in the database is definitely stored in utf8, via a utf8 connection in a table that supports utf8 charset.

to make this work properly you should assume that every part of the app is utf8. browser data, form data, file data, mysql table and vitally the mysql connection.

 
Many thanks, that did the trick!

Peter D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top