PHP连接MSSQL配置教程
为了能让PHP连接MSSQL,系统需要安装MSSQL,PHP,且在PHP.ini中的配置中,将 ;extension=php_mssql.dll前面的;去掉
配置php
1、打开php.in将extension=php_mssql.dll的注释符号去掉。
2、打开php.in将mssql.secure_connection = Off改为on。
3、将php_mssql.dll拷贝到php.in中extension_dir 指定的目录或者系统system32目录下。(php_mssql.dll在php压缩安装包中有)。
以上步骤完成后需要重启apache。
测试代码
1.连接MSSQL
代码如下 | 复制代码 |
$conn=mssql_connect("实例名或者服务器IP","用户名","密码"); //测试连接 |
注意:实际使用中发现 如果通过php压缩文件手工安装php到iis下,必须重启机器而不仅仅是iis。
4、需要保证php或者系统系统system32下有ntwdblib.dll,查看属性确保其版本为8.00.194而不是7.0......
其他设置
如果php apache Sql Server2000都在同一台机器上,访问基本没有问题了。
如果Sql Server2000和php机器是分离的,需要确认ping sqlserver所在机器的机器名能通,如过不通,修改php所在机器的system32driversetc下的hosts文件,增加一行 sqlserver所在机器的机器ip sqlserver所在机器的机器名字。
如果还是无法访问,需要确认php所在的机器有无暗转mdac。要不索性安装一下sqlserver的客户端好了。
3.配置sqlserver
a. 运行 SQL Server 配置管理器:SQL Server Configuration Manager,打开协议 Protocols
b. 允许命名管道 "named pipes" 和 "tcp/ip"
c. 右键点击 "tcp/ip",打开属性 Properties 标签 "IP addresses"
d. 在 TCP 动态端口 "TCP Dynamic Ports" 填入 1433
e. 重启 SQL Server
mssql_connect() Unable to connect to server
确认SQLServer2005服务器正常.检查 TCP/IP已经启用
同时右键查看属性:
已经启用是否选择是
确认服务器正确之后,再确认ntwdblib.dll 文件位置是否放到了 c:/windows/system32下
同时要保证ntwdblib.dll 这个文件的版本和sqlserver的版本对应:
下面是对应关系:
2.ntwdblib.dll 版本为 2000.2.8.0 是 对应 SqlServer2000(这个是网络查资料和猜测,没装2000)
2.ntwdblib.dll 版本为 2000.80.194.0 是 对应 SqlServer2005(这个是用实验证明可以用,本人就是用笔记本装了2005)
3.ntwdblib.dll 版本为 2000.80.2039 是 对应 SqlServer2008(这个是猜测没有装2008)
测试代码
代码如下 | 复制代码 |
|

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]
