<?PHP$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 前面是全角空格
代码是网上复制来的吧?
我操,复制粘贴害死人啊,谢谢楼上