Home > Backend Development > PHP Tutorial > mysql_fetch_array执行不出结果 也不报错 请指导那错了

mysql_fetch_array执行不出结果 也不报错 请指导那错了

WBOY
Release: 2016-06-13 11:53:43
Original
859 people have browsed it

mysql_fetch_array执行不出结果 也不报错 请指点那错了

<br />  <?php <br />    $uid=$_COOKIE['uid'];<br />    $sql="SELECT * FROM `user` WHERE `id`='$uid'";<br />    echo "$sql";<br />    $query=mysql_query($sql);<br />    $rs=mysql_fetch_array($query);<br />    echo $rs['username'];<br />  ?><br />
Copy after login

echo "$sql"的结果在mysql中执行正常没有错误 即获取cookie参数是正常的
可执行mysql_fetch_array就没有结果 好奇怪
------解决方案--------------------
print_r($rs); 看看是什么结果
------解决方案--------------------
连接数据库失败。
可以这样写来调试
$query=mysql_query($sql) or die(mysql_error());
------解决方案--------------------
连接数据库失败

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