配置wamp连接ms sql server 2008

发布于 2024-12-24 22:50:46 字数 835 浏览 0 评论 0原文

我从未将 PHP 连接到 MS sql 服务器,因此按照在线教程配置 wamp 与 sql 服务器连接时遇到了困惑和麻烦。我在同一台计算机上安装了由 Apache 版本 2.2.21 和 PHP 版本 5.3.8 以及 MS Sql server 2008 组成的 wamp。 我下载了 Microsoft Drivers for PHP for SQL Server(SQLSRV20.EXE)。并将文件解压到D:\wamp\bin\php\php5.3.8\ext。然后我从 wamp 图标托盘中打开 php.ini 文件,并提供扩展路径:extension=php_sqlsrv_53_ts_vc9.dll 和 extension=php_sqlsrv_53_nts_vc9.dll。 我已将 php 文件名 testsqlserver.php 放在 wamp 的 www 根文件夹中,其代码如下所示:

<?php
   $server = 'mypc/SQLEXPRESS';
   $link = mssql_connect($server,'sa','password');
   if(!$link)
   {
      die('something went wrong');
   }
?>       

当我通过浏览器以 localhost:8080\testsqlserver.php 调用 testsqlserver.php 时。它显示错误: 致命错误:调用 D:\wamp\www\connectsqlserver.php 中未定义的函数 mssql_connect()

我做错了吗?或者还有什么要做的吗?我已经通过不同的在线搜索但无法获得确切的解决方案。有人能帮助我吗,我将不胜感激

I have never connect PHP to MS sql server so getting confusion and trouble for configuring wamp to connect with sql server by following online tutorial. I have install wamp that consist of Apache Version 2.2.21 and PHP Version 5.3.8 and MS Sql server 2008 on same machine.
I downloaded the Microsoft Drivers for PHP for SQL Server(SQLSRV20.EXE). and extracted the file to D:\wamp\bin\php\php5.3.8\ext. Then I opened the php.ini file from wamp icon tray and provide the extension path as extension=php_sqlsrv_53_ts_vc9.dll and extension=php_sqlsrv_53_nts_vc9.dll.
I have put php file name testsqlserver.php in www root folder of wamp which code is shown below:

<?php
   $server = 'mypc/SQLEXPRESS';
   $link = mssql_connect($server,'sa','password');
   if(!$link)
   {
      die('something went wrong');
   }
?>       

When I called testsqlserver.php through browser as localhost:8080\testsqlserver.php. It shows the error:
Fatal error: Call to undefined function mssql_connect() in D:\wamp\www\connectsqlserver.php

am I doing wrong way? or is there anything more to do for this.I have gone through different online search but unable to get the exact solution for this. Would someone help me, it would be great appreciation

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暮光沉寂 2024-12-31 22:50:46

您必须编辑位于 WAMP 目录中的 php.ini 文件。其中应该有几行用于加载 MS SQL 扩展,但它们被注释掉了;您需要做的就是取消注释这些行并重新启动 Apache。

我正在使用 XAMPP,我的 php.ini 中必须取消注释的行是:

;extension=php_mssql.dll

;extension=php_pdo_mssql.dll

You have to edit your php.ini file located within the WAMP directory. There should be a few lines in there for loading the MS SQL extension but they are commented out; all you need to do is uncomment those lines and restart Apache.

I'm using XAMPP and the lines within my php.ini that I have to uncomment are:

;extension=php_mssql.dll

;extension=php_pdo_mssql.dll

浅浅淡淡 2024-12-31 22:50:46

您下载的 Microsoft Drivers for PHP for SQL Server ,支持 sqlsrv_connect() 与 sql server 数据库建立连接

您应该使用 sqlsrv_connect() 函数与 sql server 连接,mssql_connect 已被弃用< /strong>
您可以通过以下链接获取函数及其描述形式的完整列表

http://msdn.microsoft.com/en-us/library/cc296152%28SQL.90%29.aspx

Microsoft Drivers for PHP for SQL Server which you have downloaded , support sqlsrv_connect() to establish connection with sql server database

You should use sqlsrv_connect() function to connect with sql server , mssql_connect is depreciated
you can get full list of function and their description form following link

http://msdn.microsoft.com/en-us/library/cc296152%28SQL.90%29.aspx

野生奥特曼 2024-12-31 22:50:46

我目前不使用 wamp,但我认为您应该为此启用 PHP 扩展。单击状态栏中的 wamp 图标并启用 php_mssql 和 php_pdo_mssql 扩展,然后重新启动 apache 服务。

I do not currently use wamp, but I think you should enable PHP extensions for this. Click on wamp icon in status bar and enable php_mssql and php_pdo_mssql extensions, then restart apache service.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文