Hi Folks,
I'm new to PHP (I'm a classic ASP programmer), and I thought the best way to tackle learning PHP, would be to just jump in and create a small app...so that's what I'm doing....
My web server is IIS6, and I'm connecting to a MS SQL 2000 database on a different server. I can successfully connect to the SQL database using ADO in PHP as follows:
$conn = new COM ("ADODB.Connection")
or die("Cannot start ADO");
$connStr = "PROVIDER=SQLOLEDB;SERVER=SQLSERVER;UID=USER;PWD=PASSWORD;DATABASE=MYDB";
$conn->open($connStr);
The problem is, there doesn't seem to be a good way in ADO to do queries that are SQL Injection-proof. So I am trying to get Paramiterized Queries working (with mssql_bind)....this is where I run into trouble - I can't even get that far, because I can't connect to the DB....my code is:
$connect = mssql_connect('SQLSERVER', 'USER', 'PASSWORD');
mssql_select_db('MYDATABASE', $connect);
The mssql_connect generates an error : Unable to connect to server
I've done a fair share of research, and I've tried the following:
1) making sure extension=php_mssql.dll is uncommented in the php.ini file
2) making sure the mssql_connect function is available with the function_exists (it is)
3) making sure mssql.secure_connection = off in the php.ini file
4) I've tried using the server IP with port, and different variations
5) I've tried using a different ntwdblib.dll version, although I'm not sure I had it in the right place
I just don't know what else to try....does anyone have any suggestions?
Thanks!
mssql_connect problems - need advice
Moderator: General Moderators
Re: mssql_connect problems - need advice
This might be a long shot, but try specifying the port in the connection (you pass it along with the host name, separated with a comma). Otherwise it uses the port defined in the php.ini, which might not be what your SQL server is listening at.
Re: mssql_connect problems - need advice
Yes, I've tried that (see #4)...I've tried the IP address instead of the server name, with and without the port, etc....to no avail....
Re: mssql_connect problems - need advice
Run phpinfo() and look for the part with information on the mssql extension. It might reveal potential problems
Re: mssql_connect problems - need advice
All looks good to me:
MSSQL Support enabled
Active Persistent Links 0
Active Links 0
Library version 7.0
Directive Local Value Master Value
mssql.allow_persistent On On
mssql.batchsize 0 0
mssql.compatability_mode Off Off
mssql.connect_timeout 5 5
mssql.datetimeconvert On On
mssql.max_links Unlimited Unlimited
mssql.max_persistent Unlimited Unlimited
mssql.max_procs Unlimited Unlimited
mssql.min_error_severity 10 10
mssql.min_message_severity 10 10
mssql.secure_connection Off Off
mssql.textlimit Server default Server default
mssql.textsize Server default Server default
mssql.timeout 60 60
MSSQL Support enabled
Active Persistent Links 0
Active Links 0
Library version 7.0
Directive Local Value Master Value
mssql.allow_persistent On On
mssql.batchsize 0 0
mssql.compatability_mode Off Off
mssql.connect_timeout 5 5
mssql.datetimeconvert On On
mssql.max_links Unlimited Unlimited
mssql.max_persistent Unlimited Unlimited
mssql.max_procs Unlimited Unlimited
mssql.min_error_severity 10 10
mssql.min_message_severity 10 10
mssql.secure_connection Off Off
mssql.textlimit Server default Server default
mssql.textsize Server default Server default
mssql.timeout 60 60
Re: mssql_connect problems - need advice
Ok this is my last try cause I'm out of ideas 
Is it possible the SQL server crashed? open Services under Adminstration Tools and restart it manually.
Oh and check the version of PHP you are using... it's such a remote chance but perhaps switching to the latest version could help.
Is it possible the SQL server crashed? open Services under Adminstration Tools and restart it manually.
Oh and check the version of PHP you are using... it's such a remote chance but perhaps switching to the latest version could help.
Re: mssql_connect problems - need advice
Thanks....
Yeah the SQL server is running (40 other databases) - so I know it's up...
As for PHP, I'm running the latest version....
Thanks for the ideas....
Yeah the SQL server is running (40 other databases) - so I know it's up...
As for PHP, I'm running the latest version....
Thanks for the ideas....