假设有表user_info如下:
uid username password
1 a 123现在PHP中执行查询:
select * from user_info where uid = 1然后用以下语句访问查询结果 :
while(($row = @$result->fetch_assoc()) !== NULL)
{
if($row['uid'] == 1)
{
}
}会得到notice:Undefined index: uid
如果将查询sql改成:
select uid, username, password from user_info where uid = 1
则可以顺利访问到对应字段。不知是何原因阿?
uid username password
1 a 123现在PHP中执行查询:
select * from user_info where uid = 1然后用以下语句访问查询结果 :
while(($row = @$result->fetch_assoc()) !== NULL)
{
if($row['uid'] == 1)
{
}
}会得到notice:Undefined index: uid
如果将查询sql改成:
select uid, username, password from user_info where uid = 1
则可以顺利访问到对应字段。不知是何原因阿?
试试这样看可行 $sqlgg="select * from user_info where uid = 1 ";
$conns=mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db($db_name,$conns);
$rts=mysql_query($sqlgg);
$rss=mysql_fetch_array($rts);
echo $rss["uid"];
楼主print_r($row)看看是什么数组????
是不是空格那些问题,不可见的字符串作为了key,print_r看不见。