Home > Backend Development > PHP Tutorial > How to solve the problem of garbled Chinese characters in php and garbled Chinese characters in the database

How to solve the problem of garbled Chinese characters in php and garbled Chinese characters in the database

WBOY
Release: 2016-07-25 09:04:12
Original
863 people have browsed it
  1. /*
  2. @Solution to garbled Chinese characters in the library
  3. @bbs.it-home.org
  4. */
  5. include_once("conn.php");
  6. include_once("include. php");
  7. mysql_query("set names 'gbk'")or die("Failed to set character library n");
  8. mysql_select_db($db)or die("Failed to connect to database!n");
  9. $exec = " select * from $table";
  10. //echo $exec;
  11. $result = mysql_query($exec,$conn)or die("Query database failed 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. ?>
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template