返回:
Notice: Undefined index: UserId in D:/_PHP_Test/Test2/test_connLocalDB.php on line 32 ::王小一
Notice: Undefined index: UserId in D:/_PHP_Test/Test2/test_connLocalDB.php on line 32 ::王小二
Notice: Undefined index: UserId in D:/_PHP_Test/Test2/test_connLocalDB.php on line 32 ::王小三
Notice: Undefined index: UserId in D:/_PHP_Test/Test2/test_connLocalDB.php on line 32 ::王小四
Notice: Undefined index: UserId in D:/_PHP_Test/Test2/test_connLocalDB.php on line 32 ::王小五
分析:
mssql_fetch_row(),和用mssql_fetch_array()加上第二个可选参数 MYSQL_NUM 完全相同。从和指定的结果标识关联的结果集中取得一行数据并作为数组返回。每个结果的列储存在一个数组的单元中,偏移量从 0 开始。 注意,这里是从0开始偏移,不能用key值(字段名)来取值,只能用索引来取值。因此,这里使用$row['key值']无法取到值。 方法名: mssql_fetch_assoc()
返回:
Notice: Undefined offset: 1 in D:/_PHP_Test/Test2/test_connLocalDB.php on line 43 1::
Notice: Undefined offset: 1 in D:/_PHP_Test/Test2/test_connLocalDB.php on line 43 2::
Notice: Undefined offset: 1 in D:/_PHP_Test/Test2/test_connLocalDB.php on line 43 3::
Notice: Undefined offset: 1 in D:/_PHP_Test/Test2/test_connLocalDB.php on line 43 4::
Notice: Undefined offset: 1 in D:/_PHP_Test/Test2/test_connLocalDB.php on line 43 5::
分析:
mssql_fetch_assoc() 和用mssql_fetch_array()加上第二个可选参数 MYSQL_ASSOC 完全相同。它仅仅返回关联数组。这也是 mssql_fetch_array()起初始的工作方式。因此用$row[索引值]无法取到值。 方法名: mssql_fetch_array()
测试:
[U]复制代码[/U] 代码如下: