PHP + MSSQL problems...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
dbarney
Forum Newbie
Posts: 6
Joined: Tue Apr 20, 2004 11:32 am

PHP + MSSQL problems...

Post by dbarney »

Okay.

Im using Windows2k3 Web Edition for hosting IIS6.0
Im using Windows2k3 Server for hosting a SQL2000 Database

Both work great except the fact that i can not get PHP to connect to the SQL Database.

I can get into the database using Access and a program called MSDE i think. It worked fine on the webserver.

PHP was working previously very well with SQL2000, but I restarted the servers, and it just stopped working.

Does anyone have any suggestions?

I have the dll's located properly, the extension is in the extensions directory. Im using SQL Authetication... Im really lost here..

Thanks!
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

Does php work at all? if you run phpinfo(), do you get the data?
dbarney
Forum Newbie
Posts: 6
Joined: Tue Apr 20, 2004 11:32 am

Post by dbarney »

Yes it does.
Works with phpinfo() and a few other self-made scripts
This is a SQL only-problem....

Again, i can connect in from the server using 3rd party PROGRAMS though....
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

you have to use ODBC to connect ot mssql, right?
dbarney
Forum Newbie
Posts: 6
Joined: Tue Apr 20, 2004 11:32 am

Post by dbarney »

Nope. They have an extension for it which can be setup from the php.ini (if you used binary).
dbarney
Forum Newbie
Posts: 6
Joined: Tue Apr 20, 2004 11:32 am

Post by dbarney »

Time to confuse things up a bit more....

Ok, to install MSSQL drivers for PHP you have to get the ntwdblib.dll from the PHP Install, and move it to the c:\windows\system32... Or atleast thats what i had read. I try that, and i get a cannot connect error. BUT if i use the ntwdblib.dll from the SQL install, i get:

Warning: mssql_connect(): message: Login failed for user 'su'. (severity 14) in E:\wwwroot\flmanage.com\db.php on line 5
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

well then that means that its working and you are just using the wrong username to log in, right?
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

should not the user be sa as the default user? Try a default user to ensure you can talk to the server before you try adding a more limited user...

PS it might not be the password, but the where the user is connecting from
dbarney
Forum Newbie
Posts: 6
Joined: Tue Apr 20, 2004 11:32 am

Post by dbarney »

Well, sa is the default login. And thats what im using.

And, again, using 3rd party software, on the same local ip network, i can connect using sa perfectly fine.
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

Warning: mssql_connect(): message: Login failed for user 'su'. (severity 14) in E:\wwwroot\flmanage.com\db.php on line 5
Your error shows SU as the user, not sa
dbarney
Forum Newbie
Posts: 6
Joined: Tue Apr 20, 2004 11:32 am

Post by dbarney »

Ok, i have figured out the problem
It was based on two different things.

A. Do not use the php ntwdblib.dll
B. Use the SQL version of ntwdblib.dll
C. Use the proper "sa" not "su"

I had done soo many variations of dll's and logins, i accidentally
typed su. easily overlooked after spending 6 hours doing this

Thanks alot
Post Reply