导航首页 » 技术教程 » php下使用以下代码连接并测试
全站头部文字 我要出现在这里
php下使用以下代码连接并测试 414 2023-12-09   


<?php

$myServer = "localhost"; //主机
$myUser = "sa"; //用户名
$myPass = "password"; //密码
$myDB = "Northwind";? //MSSQL库名

$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");

$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");

$query = "SELECT TitleOfCourtesy+' '+FirstName+' '+LastName AS Employee ";
$query .= "FROM Employees ";
$query .= "WHERE Country='USA' AND Left(HomePhone, 5) = '(206)'";

$result = mssql_query($query);
$numRows = mssql_num_rows($result);

echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";

while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["Employee"] . "</li>";
}




!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103