


I configured a new server today. The configuration is IIS php. When running, I found an error when php connected to the remote mssql database. The error code is as follows:
Warning: mssql_connect(): Unable to connect to server:
Thinking about it, it was all fine before, so what happened? Later, I searched online and found an article, only to find out that the server needs to install mssql in order to use php to connect to mssql. Originally, I didn’t need to use mssql on the new server, but now I have no choice but to install it. Yes, after installing mssql there will be no problem.
I was thinking, what would happen if it was Apache PHP on Linux? It is impossible to install mssql, haha, I am dizzy.
Below is an article I found.
php configuration:
Set as follows in the php.ini file and find
;extension=php_mssql.dll remove the semicolon in front
Find extension_dir = d:extension
Your php.ini may not contain d:extension
Change the path to php_mssql.dll under the extensions directory under the PHP installation directory. If you have not moved it to another place (assuming that your PHP installation path is d:php)
Just change it to extension_dir=d:phpextensions
Then restart the web server
This is easy to do, but after completing such settings, it still cannot be connected. The error message is as follows:
MS SQL Server database connection error! Please check whether the database host variable settings are correct!!!
I checked the variable settings of the host over and over again, and there were no problems with those settings. I browsed through the web and found the following clues:
php.com information:
I am trying to connect to SQL Server 2000 from PHP
I bumped to the following warning:
Warning: mssql_connect(): Unable to connect to server: SERVERPortal
.......on line 5
on line 5 there is:
$db_connect = mssql_connect('SERVERPortal', 'sa', 'my_passwd');
I did the following
1.enabled php_mssql.dll extension in PHP.ini
2.every dll is in proper place(System32 or PHP folder),including ntwdblib.dll
I search lots of profile throught web ,but no one give me proper answer to resolve it.
after a few hours ,I found the problem was caused by
ntwdblib.dll ,which version is 7.00.839 ,when I replaced old ntwdblib.dll with the new
ntwdblib.dll ,which version is 8.00.194 ,all problems are solved.
We had some, read A LOT, of problems with MSSQL under Windows 2003.
We had 2 the same windows, php, php-ini, everything machines but only one could connect.
Unable to connect was the error message.
Finnaly we checked the version of ntwdblib.dll and the one distributed with PHP was 7.00....
and the version of the one on the SQL Server install was 8.00.... so we copied this one in
the php and apache dir and it worked.
The problem was found in this way, and it was ntwdblib.dll
that caused the trouble.
The main function of ntwdblib.dll is to provide sql server connection service.
The PHP version I use is 4.3.9. In the windows/system32/ of the server where it is installed, I found that the version of the ntwdblib.dll file is 2000.2.8.0. This version supports SQL Server 7.0, because when installing PHP Overwrite all files under dlls to the system
directory, so when I use it to connect to sql server 2000, of course I will be unable to connect.
Later, I found that the version of ntwdblib.dll was 2000.80.2039.0 on a server where SQL Server 2000 was installed normally. I copied this file to overwrite the previous version. After restarting the server, everything was normal.
Supplement: If the database name starts with a number, it will also prompt that it cannot be opened. At this time, it is very simple. Use square brackets [ ]
for the name of the database.
You can do it by bracketing it. If 123bbs is rewritten as [123bbs], there will be no problem. In addition, if your database name conflicts with the reserved words in SQL Server, this situation will also occur. You can also solve it by using square brackets.
Finally, the problem of PHP being unable to correctly connect to sql server 2000 was finally solved. Although it took most of a day, the harvest was still great. Posting it now will save brothers who encounter the same problem from taking some detours.

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。


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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

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