Home > Backend Development > PHP Tutorial > php+mysql有数据,但查询不到数据问题

php+mysql有数据,但查询不到数据问题

WBOY
Release: 2016-06-23 14:22:28
Original
1456 people have browsed it

一小段程序,在本地完全正常,传到服务器上执行时就是查不到数据,但在远程phpMyAdmin中用SQL方式查询也能查询得到,搞不懂了,有过类似经历的来帮忙啊.代码如下:

$query = "select name,class,schoolid from studentslist where class like '$query_class' and name like '$query_name' ";						echo $query.'<br>';                        			$result = MySql_query($query, $id);//			if($result)echo 'query success';                        $totalnum = MySql_num_rows($result);echo $totalnum.' records found.';                        if ($totalnum < 1) {                            echo "<p align=left>未找到 " . $query_class . " 班姓名为 " . $query_name . " 的学生记录。</p>";                        } 
Copy after login


回复讨论(解决方案)

可能是编码的问题,加上: mysql_query("set name utf8"); 看看

错了,这样
 mysql_query("set names utf8"); 

真的可以了, 结题, 给分, 不过你能再回贴解释一下为什么这样吗? 谢谢!

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