xxx.php保存时选择utf8编码,页头最好加上
header('conten-type:text/html;charset=utf-8');
在执行CRUD操作前先执行一下
mysql_query("set names utf8");
测试代码xxx.php如下:
<?php header('conten-type:text/html;charset=utf-8'); mysql_connect("localhost", "root", "password") or die("Could not connect: " . mysql_error()); mysql_select_db("test"); mysql_query("set names utf8"); $str = "CHN 软件开发有限公司,JPN ソフトウェア開発株式会社,KOR 소프트웨어 개발 유한 공사,RUS Суд программного обеспечения".time(); $sql = "insert into tablename4 (varchar1, varbinary1 ) values ('".$str."','".$str."')"; echo $sql."<hr>"; mysql_query($sql); $result = mysql_query("SELECT id, varchar1 ,varbinary1 FROM tablename4"); while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { printf ("ID: %s , varchar1: %s, varbinary1: %s<br>", $row[0], $row["varchar1"], $row["varbinary1"]); } mysql_free_result($result); ?>