mysql搜索不到数据,急呀,在线求救

WBOY
Release: 2016-06-23 14:24:43
Original
933 people have browsed it

网站采用utf-8保存数据。读取数据,写入数据都采用:
mysql_query("set names 'utf-8'")

搜索数据库表中时,只要是中文的,大部分搜索不出来。

$add=$sql->mdenin_select("SELECT * FROM movie WHERE `a0`  LIKE '%$so%' LIMIT 0 , 1000");





回复讨论(解决方案)

你的截图是 phpmyadmin 的吧?中文不都是乱码吗?

注释掉 mysql_query("set names 'utf-8'")
再试试

另外 mysql 的 utf-8 字符集应写作 utf8
所以你只不过是按 mysql 默认字符集 latin1 存取的

你的截图是 phpmyadmin 的吧?中文不都是乱码吗?

注释掉 mysql_query("set names 'utf-8'")
再试试
这个是由utf-8保存的数据,只是搜索时不能搜到数据,注释掉mysql_query("set names 'utf-8'"),还是搜索不到数据

另外 mysql 的 utf-8 字符集应写作 utf8
所以你只不过是按 mysql 默认字符集 latin1 存取的
那怎样将这些数据转成utf8

读取乱码字段的内容到变量 $s
echo base64_encode($s);
贴出结果

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!