问题描述
我正在使用
- Xampp版本3.2.1和PHP版本5.6.8.
- Microsoft Azure SQL服务器
目标
我正在尝试创建一个可访问我的数据库的Web应用程序,并且能够 SELECT , INSERT , UPDATE 和 DELETE 记录.
I am trying to create a web app that will access to my database, and be able to SELECT, INSERT, UPDATE and DELETE records.
问题
我无法连接到数据库服务器
I cannot connect to the database server
错误
代码
<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>
这就是我尝试过的
- 我已经安装了Microsoft PHP for SQL驱动程序,并按照所有说明加载了驱动程序,但是它似乎无法正常工作!
- 我将
php_sqlsrv_56.ts.dll
文件添加到了PHP的扩展文件夹中,并且还添加了php_pdo_sqlsrv_56.ts.dll
. - 我还将
extension=php_sqlsrv_56.ts.dll
行添加到了php.ini文件中.
- 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.
任何帮助将不胜感激!
推荐答案
一步一步
-
从以下位置下载SQLSRV32.EXE(用于SQL Server的Microsoft PHP驱动程序): http://www.microsoft.com/en-us/download/details.aspx?id=20098
选择路径:C:\ xampp \ php \ ext
Choose path: C:\xampp\php\ext
-
取消注释或在
php.ini
从XAMPP控制面板重新启动Apache(停止/启动)
Restart Apache from XAMPP Control Panel (Stop/Start)
我对其进行了测试,并且效果100%
I tested it and it works 100%
您可以在官方Microsoft Git存储库中找到最新的编译二进制文件.
You can find the most recent compiled binaries in the official Microsoft Git repository.
这篇关于致命错误:调用C:\ xampp \ htdocs中未定义的函数sqlsrv_connect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!