将PHP连接到SQLServer时出错

将PHP连接到SQLServer时出错,php,sql-server,Php,Sql Server,我正在使用连接到sqlserver的php脚本,但它不起作用。 //connection to the database $dbconn = mssql_connect($Server) or die("Couldn't connect to SQL Server on $Server"); if($dbconn)echo 'Connected'; //select a database to work with $selected = mssql_select_db($DB, $dbcon

我正在使用连接到sqlserver的php脚本,但它不起作用。
//connection to the database
$dbconn = mssql_connect($Server)
  or die("Couldn't connect to SQL Server on $Server");
if($dbconn)echo 'Connected';
//select a database to work with
$selected = mssql_select_db($DB, $dbconn)
  or die("Couldn't open database $myDB");
!![运行脚本时出现此错误,我正在使用windows身份验证][1]

检查


使用mysql\u Connect()连接

范例

$con = mysql_connect("localhost","me","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mssql
扩展不推荐使用。改为使用。本地主机正在运行吗?看起来不是。还有一篇帖子也有同样的问题:我只需要将php连接到sqlserver,我就有windows7 32位、wamp服务器、PHPV5.3.0、apache2.2.11。我已经下载了SQLSRV30.EXE并将文件复制到php的ext文件夹,还将ntwdblib.dll复制到php目录和appache bin目录。在php.ini中,我添加了以下扩展名extension=php_sqlsrv_53_ts.dll extension=php_pdo_sqlsrv_53_ts.dll。但我仍然收到以下消息:致命错误:在第5行的C:\wamp\www\TPphp\SQLServer\tp.php中调用未定义的函数dl()。如何将php连接到sqlserver?“sqlserver”代表Microsoft SQL Server,而不是MySQL<代码>mysql函数将不会连接到它。您早就应该了解到的新概念:
mysql\uu
函数已被弃用,不应使用。
$dbconn =mysql_connect(servername,username,password);
$con = mysql_connect("localhost","me","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }