一个很奇怪的有关问题:同样的一条sql语句,在mysql中能查到记录,而在php中却查不到

WBOY
Release: 2016-06-13 11:56:53
Original
997 people have browsed it

一个很奇怪的问题:同样的一条sql语句,在mysql中能查到记录,而在php中却查不到
具体如下:
mysql中数据表结构:


sql语句:
SELECT ID FROM tradeDetails WHERE userName = '李四' AND goodsID ='1'

php代码:

<?php<br />mysql_connect("localhost","root","root");<br />mysql_query("set names utf-8");<br />mysql_select_db("test");<br /><br />// 为方便说明问题,我把条件参数设为常量<br />$querySql="SELECT ID FROM tradeDetails WHERE userName = '李四' AND goodsID ='1'"; <br /><br />$rs=mysql_query($querySql);<br />$totalRows_myrs=mysql_num_rows($rs); <br />echo $totalRows_myrs;<br />?>
Copy after login


我将sql语句放到mysql中执行能查到1条记录,而php页面执行时,却不能查到记录。求解。
------解决方案--------------------
mysql_query("set names utf8");
------解决方案--------------------
php文件的本身也要是utf8编码。
------解决方案--------------------
php文件的本身也要是utf-8编码

Related labels:
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