note 76256 deleted from function.mssql-connect by cmb
| From: | cmb@php.net | Date: | Sun, 11 Aug 2019 12:50:53 +0000 |
| Subject: | note 76256 deleted from function.mssql-connect by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211867@lists.php.net to get a copy of this message | ||
Note Submitter: animefan1003 at yahoo dot com
----
If you cannot connect to an SQL Server instance after trying all of the above, look in the registry
using regedit.exe at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL
Server\SQLEXPRESS\MSSQLServer\SuperSocketNetLib\Tcp. One of the nameValue pairs has name TcpPort and
a value, which is the port that the SQL Server is listening on (mine was set to 1030).
Now in the SQL Server Configuration Manager, under SQL Server native client configuration->Client
protcols->TCP\IP, the default port is listed as 1433. It seems that this registry value is
overriding the setting in the SQL Server Config manager.
I changed the port number in my call to mssql_connect() to 1030 and I was able to connect. An
example string is:
<?php $database = mssql_connect('laptop2,1030', 'sa', 'password',
false); ?>. Note that for the server name, it can be the machine name, the string
"localhost" or an IP Address such as 127.0.0.1. You do not have to append
"\SQLEXPRESS" to the end of it.
Before I did this, I enabled TCP\IP connections using the SQL Server Config Manager. I also enabled
the IP address under TCP/IP to be sure it worked. In php.ini, I had the mssql.secure_connection key
set to "Off" (hence why I pass the username and pasword to mssql_connect()). I enabled
mixed authentication is SQL Server and granted logins to user "sa". I also put the updated
ntwdblib.dll in both the system32 directory and the php directory to be sure it would work.
Also, the webzilla site for the updated ntwdblib.dll file seems to be having connection issues with
their MySQL database. Instead, try http://www.userscape.com/helpdesk/index.php?pg=kb.page&id=13
.
I hope that this saves someone a few hours :-) .