欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-05-10 14:29:19
...
  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. ?>
复制代码