时间:2021-07-01 10:21:17 帮助过:21人阅读
<?php
header("Content-type:text/html;charset=utf-8");
//
$conInfo=array(‘Database‘=>‘dbname‘, ‘UID‘=>‘user‘, ‘PWD‘=>‘password‘);
$conn=sqlsrv_connect(‘servername/IP‘, $conInfo);
$sql = "SELECT * FROM Product where ProductNo=10001";
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$stmt = sqlsrv_query($conn, $sql , $params, $options );
$row_count = sqlsrv_num_rows( $stmt );
/*判断连接成功与否:*/
if(!$conn) echo "FAILD!连接错误,用户名密码不对";
else echo "OK!可以连接";
//判断查询结果的行数
if ($row_count === false)
echo "Error in retrieveing row count.";
else
echo $row_count;
?>
php连接sql serve后如何执行sql语句
标签:type fail user connect 执行 where name 成功 rod