当前位置:Gxlcms > PHP教程 > 如何解决php中文字符乱码,中文字符入库乱码的问题

如何解决php中文字符乱码,中文字符入库乱码的问题

时间:2021-07-01 10:21:17 帮助过:29人阅读

  1. /*
  2. @中文字符入库乱码的解决方法
  3. @bbs.it-home.org
  4. */
  5. include_once("conn.php");
  6. include_once("include.php");
  7. mysql_query("set names 'gbk'")or die("设置字符库失败\n");
  8. mysql_select_db($db)or die("连接数据库失败!\n");
  9. $exec = "select * from $table";
  10. //echo $exec;
  11. $result = mysql_query($exec,$conn)or die("查询数据库失败\n");
  12. echo "";
  13. for($cout=0;$cout{
  14. $city = mysql_result($result,$cout,city);
  15. $name = mysql_result($result,$cout,name);
  16. $phone = mysql_result($result,$cout,phone);
  17. echo "
  18. ";
  19. echo "city: $city";
  20. echo "name: $name";
  21. echo "phone: $phone";
  22. echo "
  23. ";
  24. }
  25. echo "
  26. ";
  27. ?>

人气教程排行