欢迎来到福编程网,本站提供各种互联网专业知识!

php下使用以下代码连接并测试

发布时间:2008-04-09 作者: 来源:转载
php连接mysql数据库效果
复制代码 代码如下:

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

$s=@mssql_connect($myServer,$myUser,$myPass)
ordie("Couldn'tconnecttoSQLServeron$myServer");

$d=@mssql_select_db($myDB,$s)
ordie("Couldn'topendatabase$myDB");

$query="SELECTTitleOfCourtesy+''+FirstName+''+LastNameASEmployee";
$query.="FROMEmployees";
$query.="WHERECountry='USA'ANDLeft(HomePhone,5)='(206)'";

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

echo"

".$numRows."Row".($numRows==1?"":"s")."Returned

";

while($row=mssql_fetch_array($result))
{
echo"

  • ".$row["Employee"]."
  • ";
    }


    相关推荐