致命错误:调用 C:xampphtdocs 中的未定义函数 sqlsrv_connect()
我正在使用
- Xampp 3.2.1 版和 PHP 5.6.8 版.
- Microsoft Azure SQL 服务器
目标
我正在尝试创建一个可以访问我的数据库并能够SELECT、INSERT、UPDATE和UPDATE的网络应用程序strong>DELETE 记录.
<小时>问题
我无法连接到数据库服务器
<小时>错误
<块引用>致命错误:调用未定义的函数 sqlsrv_connect()C:xampphtdocsBLTEmployee_Database .php 第 25 行
<小时>
代码
<html><头><Title>员工数据库</Title></头><身体><form method="post" action="?action=add" enctype="multipart/form-data">姓氏<input type="text" name="LastName" id="LastName"/></br>名字<input type="text" name="FirstName" id="FirstNamne"/></br>邮箱地址<input type="text" name="Email" id="Email"/></br>用户ID
<小时>
这是我迄今为止尝试过的
- 我已安装 Microsoft PHP for SQL 驱动程序并按照所有说明加载驱动程序,但它似乎无法正常工作!
- 我将
php_sqlsrv_56.ts.dll
文件添加到 PHP 的 extensions 文件夹中,还添加了php_pdo_sqlsrv_56.ts.dll
. - 我还在 php.ini 文件中添加了
extension=php_sqlsrv_56.ts.dll
行.
任何帮助将不胜感激!
解决方案MSSQL 扩展在 PHP 5.3 的 Windows 上不再可用或更晚.SQLSRV,MS SQL 的替代驱动程序可从微软: »中找到最新编译的二进制文件.
I am using
- Xampp version 3.2.1 with PHP version 5.6.8.
- Microsoft Azure SQL server
GOAL
I am trying to create a web app that will access to my database, and be able to SELECT, INSERT, UPDATE and DELETE records.
PROBLEM
I cannot connect to the database server
ERROR
Fatal error: Call to undefined function sqlsrv_connect() in C:xampphtdocsBLTEmployee_Database .php on line 25
CODE
<html> <head> <Title>Employee Database</Title> </head> <body> <form method="post" action="?action=add" enctype="multipart/form-data"> Last name <input type="text" name="LastName" id="LastName"/></br> First name <input type="text" name="FirstName" id="FirstNamne"/></br> E-mail address <input type="text" name="Email" id="Email"/></br> User Id <input type="text" name="UserId" id="UserId"/></br> Password <input type="password" name="Password" id="Password"/></br> <input type="submit" name="submit" value="Submit"/> </form> <?php $serverName = "jy4nij6vuy.database.windows.net,1433"; $connectionOptions = array("Database" => "robertfarb", "UID" => "robertFarb", "PWD" => "******"); $conn = sqlsrv_connect($serverName, $connectionOptions); if ($conn === false) { die(print_r(sqlsrv_errors(), true)); } ?> </body> </html>
THIS IS WHAT I TRIED SO FAR
- I have installed the Microsoft PHP for SQL drivers and followed all the instructions to load the driver, but it does not seem to be working!
- I added the
php_sqlsrv_56.ts.dll
file to the extensions folder of PHP, and also thephp_pdo_sqlsrv_56.ts.dll
.- I also added the
extension=php_sqlsrv_56.ts.dll
line to the php.ini file.Any help would be much appreciated!
解决方案The MSSQL extension is not available anymore on Windows with PHP 5.3 or later. SQLSRV, an alternative driver for MS SQL is available from Microsoft: » http://www.microsoft.com/en-us/download/details.aspx?id=20098
Step by Step
Download SQLSRV32.EXE (Microsoft Drivers for PHP for SQL Server) from: http://www.microsoft.com/en-us/download/details.aspx?id=20098
Choose path: C:xamppphpext
Uncomment or Append
extension = php_sqlsrv_56_ts.dll
inphp.ini
Restart Apache from XAMPP Control Panel (Stop/Start)
I tested it and it works 100%
You can find the most recent compiled binaries in the official Microsoft Git repository.
相关文章