将PHP连接到Microsoft SQL Server

时间:2018-09-03 12:08:00

标签: php sql sql-server

几乎已经列出了将php连接到Microsoft SQL Server的所有解决方案。

我正在使用安装了xampp的Windows 64位计算机,并尝试连接到Microsoft sql Server Management Studio。

我已将php_pdo_sqlsrv_72_ts.dll和php_sqlsrv_72_ts.dll添加到C:\ xampp \ php \ ext

我还在C:\ xampp \ php \ php.ini中提供的php.ini中添加了以下几行:

extension = php_pdo_sqlsrv_72_ts.dll;在03-09-2018上添加,用于连接到ms sql extension = php_sqlsrv_72_ts.dll;在03-09-2018上添加,用于连接到ms sql

但是,我一直收到致命错误

Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\test.php:14 Stack trace: #0 {main} thrown in C:\xampp\htdocs\test.php on line 14

<?php

$serverName = "XXXX";
$uid = "abcd";
$pwd = "Abcd1234";
$databaseName = "databasename";


$connectionInfo = array( "UID"=>$uid,
                         "PWD"=>$pwd,
                         "Database"=>$databaseName);

    /* Connect using SQL Server Authentication. */
    $conn = sqlsrv_connect( $serverName, $connectionInfo);

    $tsql = "SELECT * FROM SRC_transaction";

/* Execute the query. */

$stmt = sqlsrv_query( $conn, $tsql);

if ( $stmt )
{
     echo "Statement executed.<br>\n";
}
else
{
     echo "Error in statement execution.\n";
     die( print_r( sqlsrv_errors(), true));
}
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);

?>

0 个答案:

没有答案