Home > Backend Development > PHP Tutorial > 为啥mysql客户端返回有结果,而php 拿不到呢

为啥mysql客户端返回有结果,而php 拿不到呢

WBOY
Release: 2016-06-13 12:54:14
Original
856 people have browsed it

为什么mysql客户端返回有结果,而php 拿不到呢?
RT,我在mysql的客户端命令行上面执行SQL语句:
    select count(*) as amount from main where id = 2;
可得到结果
+--------+
| amount |
+--------+
|      1 |
+--------+
但是在php程序里面
$sql1="select count(*) as amount from main where id = 2";
$reqult = mysql_query ( $sql1 );
echo $sql1;
$row = mysql_fetch_row ( $reqult );
$amount = $row [0];
这里的$sql1永远是空值!
而且我把$sql1换成select count(*) as amount from main; 这句又可以正常取到值,
请大侠帮小弟看哈这是个什么问题呗!
我都被这个小问题给弄晕了!
多谢!

mysql php sql query
------解决方案--------------------
var_dump($row);  //是什么结果
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