Hi,
I have MS SQL Server set up on a win2k box (and am running
my PHP scripts on the same box that
SQL Server is on) ... not connected to a network and
just using the command line version of PHP ... (no web server)
I set up ODBC with a DSN for the login and password I installed in SQLServer
I set up the DSN for "local" i.e. on the local server
(I also tried it using the server name (in this case TASK5E01 with similar
results)
using ADOdb with a few drivers that reqire a DSN ... it all works fine.
This worked fine for example:
$db =& ADONewConnection('odbc_mssql');
$db->PConnect('test1');
where test1 is the DSN I set up for ... local ... tomjones ... and password
However I tried the DSNless versions as follows:
$dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
$db->Connect($dsn,'tomjones','password');
this fails with the following error:
C:\php1>php tlj4_DSNless.php
PHP Warning: SQL error: [Microsoft][ODBC SQL Server Driver][SQL
Server]Login fa
iled for user 'tomjones'. Reason: Not associated with a trusted SQL Server
conne
ction., SQL state 28000 in SQLConnect in
C:\php1\adodb\drivers\adodb-odbc.inc.ph
p on line 164
PHP Fatal error: Call to undefined function: close() in
C:\php1\tlj4_DSNless.p
hp on line 31
SO I went one step further and loaded the native PHP mssql stuff and ran it
as follows:
$dsn = mssql_connect("localhost", 'tomjones','password') or die
("mssql_connect failed"); //test PHP mssql directly
with the following identical result:
C:\php1>php tlj4_native.php
PHP Warning: mssql_connect(): message: Login failed for user 'tomjones'.
Reason
: Not associated with a trusted SQL Server connection. (severity 14) in
C:\php1\
tlj4_native.php on line 13
PHP Warning: mssql_connect(): Unable to connect to server: localhost in
C:\php
1\tlj4_native.php on line 13
SOOO --- what is up with this ... it must be a windows thing or the
DSNless stuff just won't work. I did some searching and found lots of
people
complaining about this error but the fixes they suggested didn't work ... I
am thinking it is a MS SQL Server set up issue but what is the point
of DSNlessness if one still has the tune the DBMS in order to get
connected ... why not just stick with ODBC which works. I wanted to be able
to connect without the hastles of using some MS GUI to set stuff up.
Thoughts? ... ideas for tests to run? ... suggestions on setting
up MS SQL Server or win2k to get around this?
As a work around, does anyone know how to set up ODBC DSNs under
program control in order to bypass the GUI?
thanks for wading though this ...
Tom