Home > Backend Development > PHP Tutorial > while($row = sqlsrv_fetch_array($query))

while($row = sqlsrv_fetch_array($query))

WBOY
Release: 2016-06-23 13:47:16
Original
1304 people have browsed it

<?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]."<br/>";	}	sqlsrv_close( $conn);}
Copy after login


回复讨论(解决方案)

28 行的 echo 前面是全角空格

代码是网上复制来的吧?

我操,复制粘贴害死人啊,谢谢楼上

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template