mssql_connect problems - need advice
Posted: Tue Dec 09, 2008 8:05 am
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!
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!