通过php向mysql数据库插入数据,然后在数据库中查看的时候全是乱码(中文),但是取出之后放在页面上仍然正常.就是通过数据库查看的时候全是乱码不能阅读.

mysql以UTF-8编码来保存中文,页面提交默认是utf-8的编码方式

数据库连接的时候,设置编码为utf-8就可以了:

$connect=mysql_connect($hostname,$sqluser,$sqlpass) or die("Fail to connect!");
$select=mysql_select_db($dbname,$connect) or die("Fail to select!");
mysql_query("set names 'utf8'");

相关文章:

  • 2021-10-15
  • 2022-03-09
  • 2022-12-23
  • 2021-11-20
  • 2021-08-27
  • 2022-12-23
  • 2021-11-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
  • 2021-10-24
  • 2021-12-08
  • 2022-12-23
  • 2021-12-15
相关资源
相似解决方案