【问题标题】:Connection Error PHP with SQL server 2012连接错误 PHP 与 SQL Server 2012
【发布时间】:2013-09-26 12:30:46
【问题描述】:

我在将 PHP 与 SQL Server 2012 连接时遇到问题。已配置和 (.dll) 文件并对其进行了配置。

在 SQL Server Management Studio 中,我创建了一个名为“helloworld”的数据库。我的SQL server 认证方式是window。

问题是在“master,msdb”等系统数据库上建立了连接,但我创建的数据库。它说:

[Microsoft][SQL Server Native Client 11.0][SQL Server]无法打开登录请求的数据库“helloworld”。登录失败。

我使用的代码是:

$serverName = "(local)"; //serverName\instanceName
$connectionInfo = array( "Database"=>"master","ReturnDatesAsStrings" => false,"CharacterSet" => 'utf-8');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";                
}else{
echo "Connection could not be established.<br />";                                
}  

任何帮助将不胜感激。我只需要与我创建的数据库而不是系统数据库建立连接。

谢谢

【问题讨论】:

    标签: php sql connection


    【解决方案1】:

    $con=mysql_connect('localhost','user','pass') 或 DIE ('未连接'); mysql_select_db("example") or die('Not Connected');

    回显“成功”;

    【讨论】:

    • 您好,它与 mysql 无关,我说我将它用于 SQL 服务器。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多