php下使用以下代码连接并测试
程序员文章站
2022-05-31 16:47:51
复制代码 代码如下:
<?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>";
}
上一篇: 也谈php网站在线人数统计
下一篇: 揭秘:说说太史慈背后那个名不见经传的小将