【问题标题】:How to connect Microsoft SQL Database using PHP如何使用 PHP 连接 Microsoft SQL 数据库
【发布时间】:2016-08-12 05:51:43
【问题描述】:

我正在尝试使用 sqlsrv_connect() php 函数连接 mssql 数据库,但它总是显示在致命错误下方。

致命错误:调用未定义函数 sqlsrv_connect()。

代码:

$server = 'xx.xxx.xxx.Xxx\sqlexpress';
$username = 'uname';
$password = 'password';
$database = 'testdb';


$connectionInfo = array( "Database"=>$database, "UID"=>$username, "PWD"=>$password);

$conn = sqlsrv_connect( $server, $connectionInfo);

if( $conn ) {
 echo "Connection established.<br />";
}else{
 echo "Connection could not be established.<br />";
 die( print_r( sqlsrv_errors(), true));
}

【问题讨论】:

    标签: php sql-server database


    【解决方案1】:

    为此,您必须下载相关的驱动程序。

    适用于 PHP 的 Microsoft SQL Server 2005 驱动程序允许 PHP 开发人员访问 SQL Server 2005 和 SQL Server 2008 数据库中的数据。该驱动程序包括对 Windows 和 SQL Server 身份验证方法、事务、参数绑定、流式传输、元数据访问、连接池和错误处理的支持。

    检查这些链接:

    How to connect to MSSQL

    Php Help Documnetation

    【讨论】:

    • hiii 感谢您的回复...我正在使用 ubuntu 和 xampp 服务器并在 ubuntu .so 文件中用作驱动程序。而且我不知道在哪个文件夹中放置了 .so 驱动程序文件。
    猜你喜欢
    • 2019-02-08
    • 1970-01-01
    • 2020-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-02
    • 2020-07-20
    相关资源
    最近更新 更多