php下使用以下代码连接并测试
程序员文章站
2023-08-24 10:00:56
复制代码 代码如下:
<?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>";
}
复制代码 代码如下:
<?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>";
}
下一篇: 预防肾炎到底有哪些方法