gpt4 book ai didi

PHP SQLSRV 连接 “Failed to get DB handle: could not find driver”

转载 作者:行者123 更新时间:2023-12-05 07:50:27 24 4
gpt4 key购买 nike

我正在使用以下代码:

try {
$hostname = "*****";
$port = 1443;
$dbname = "*******";
$username = "********";
$pw = "************";
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}

错误:

Failed to get DB handle: could not find driver

DLL 文件 已经在php/ext 中并在php.ini 中修改

我还能做什么?

最佳答案

从您正在使用的端口,很明显您正在尝试连接到 MSSQL 数据库。

PHP 文档指出,对于运行 php 5.3 或更早版本的 Windows 计算机,不建议使用 PDO 支持连接到 SQLSRV。

http://php.net/manual/en/ref.pdo-dblib.php

他们确实建议使用微软提供的 sqlsrv 驱动程序。

sqlsrv 驱动程序的链接在上面的 php 链接中。

关于PHP SQLSRV 连接 “Failed to get DB handle: could not find driver”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36134340/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com