且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么我无法使用 PHP 连接到我的 mssql 数据库?

更新时间:2023-02-22 07:45:38

有一些事情可能会导致此类问题:

There are a few things that could cause such problems:

1.) 你的模块没有加载,因为它的 VC9 而不是 VC11.检查您的系统使用的编译器版本并安装正确的驱动程序.

1.) Your modules aren't loaded because its VC9 instead if VC11. Check which compiler version your system use and install the correct driver.

2.) 检查您的 PHP 版本并为您的 PHP 版本使用正确的驱动程序,您可以在 phpinfo() 中检查.

2.) Check your PHP Version and use the correct driver for your PHP-Version your can check that in your phpinfo().

3.) 不要忘记安装 MSSQL Native Client 否则你无法连接到你的数据库,这是我每次遇到的问题.

3.) Don't forget to install the MSSQL Native Client otherwise you can't connect to your database that is the problem what I have every time.

您的代码看起来不错,如果您收到未找到 sqlsrv_connect 的错误消息,则表明模块未加载.

Your code looks good and if your get the error message that sqlsrv_connect isn't found that is a signal that the module is not loaded.

https://www.microsoft.com/en-us/download/details.aspx?id=20098