将PHP连接到SQLServer时出错

时间:2013-07-20 07:45:14

标签: 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, $dbconn)
  or die("Couldn't open database $myDB");

![运行脚本时出现此错误,我使用的是Windows身份验证] [1]

http://i.stack.imgur.com/a9ndN.jpg

2 个答案:

答案 0 :(得分:0)

检查mysql_connect()

$dbconn = mysql_connect('hostname','username','password');

答案 1 :(得分:-1)

使用mysql_connect()

进行连接
$dbconn =mysql_connect(servername,username,password);

例如

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