$pwd, "Database"=>"test");$conn = sqlsrv_connect( $serverName, $con">
当前位置:Gxlcms > PHP教程 > while($row=sqlsrv_fetch_array($query)),该怎么解决

while($row=sqlsrv_fetch_array($query)),该怎么解决

时间:2021-07-01 10:21:17 帮助过:170人阅读

while($row = sqlsrv_fetch_array($query))
$serverName = "localhost"; //数据库服务器地址

$uid = "sa"; //数据库用户名

$pwd = "66"; //数据库密码

$connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>"test");

$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn == false)

{
echo "连接失败!";

die( print_r( sqlsrv_errors(), true));
}
else
{
echo "连接成功";
//执行有结果集的SQL语句

$query = sqlsrv_query($conn, "select ID,NAME from stuff");

while($row = sqlsrv_fetch_array($query))
{
    echo $row[0]."-----".$row[1]."
";

}
sqlsrv_close( $conn);

}


------解决思路----------------------
28 行的 echo 前面是全角空格

代码是网上复制来的吧?

人气教程排行