search

Home  >  Q&A  >  body text

加入header("content-type:text/html; charset=utf-8");echo不乱码,但是数据库查询就乱了,怎么办?

加入header("content-type:text/html; charset=utf-8");echo不乱码,但是数据库查询就乱了,怎么办?

这是啥这是啥2823 days ago1054

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-10-01 00:28:25

    Add header("content-type:text/html; charset=utf-8"); the echo is not garbled, but the database query is messed up. What should I do? -PHP Chinese website Q&A-Add header("content-type:text/html; charset=utf-8"); the echo is not garbled, but the database query is messed up. What should I do? -PHP Chinese website Q&A

    Let’s take a look and learn.

    reply
    0
  • 怪我咯

    怪我咯2017-02-21 13:29:15

    在你链接数据库的下方加入查询数据库指定编码 ,向下面这样

    $link = mysqli_connect('localhost','root','密码','数据库名') ;

    $link->query("SET NAMES utf8");


    reply
    0
  • Cancelreply