Home  >  Article  >  Backend Development  >  从数据库里取数据,有数据,却echo不出来

从数据库里取数据,有数据,却echo不出来

WBOY
WBOYOriginal
2016-06-13 12:07:311000browse

从数据库里取数据,有数据,却echo不出来,紧急求助
代码如下:

$sql="SELECT * FROM wuliuuser WHERE duname='$uname' AND dupass='$upass'";
$rs=mysql_query($sql, $conn);

结果,print_r(mysql_fetch_assoc($rs)); 的结果为

Array ( [did] => 1 [duname] => wuliu001 [dupass] => 123456 [qyname] => 第一物流公司 [zhizhaono] => [zhizhaopic] => [qyjs] => [rname] => 王磊 [uids] => 1111111111 [utel] => 18603180561 [usheng] => 天津市 [ushi] => 和平区 [udizhi] => 测试地址测试地址 [regtime] => 2014-09-25 07:19:01 [regip] => 60.9.188.175 [ulxly] => 自助注册 [ubeizhu] => 无 [uzt] => 正常 ) 

说明 qyname这个字段是有内容的,但
echo $rs['qyname'];

结果确是空的,唉,工作了一晚上,可能脑子不动了,完整片段代码为


$sql="SELECT * FROM wuliuuser WHERE duname='$uname' AND dupass='$upass'";
$rs=mysql_query($sql, $conn);
print_r(mysql_fetch_assoc($rs));
echo $rs['qyname'];

------解决思路----------------------
print_r(mysql_fetch_assoc($rs)); 的结果为
echo $rs['qyname'];

改成
$result = mysql_fetch_assoc($rs);
echo $result['qyname'];

$rs只是对象句柄


Statement:
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