Jump to content

Cannot connect to MS SQL server


Recommended Posts

I have read a lot of posts today and tried a lot of solutions, but I seem to be stuck.

I am running windows 2003 Server, IIS6, PHP 5 and MSSQL Server 2005. Allon the one server.

when I try and access the database form PHP it fails with :-

Fatal error: Call to undefined function mssql_connect()

I have :-

only one php.ini on my server in c:\php (attached as a txt)

c:\php is in my path

my php.ini has :

extension_dir = "c:\php\ext"


the php_MSSQL.dll is in my c:\php\ext folder

ntwdllib.dll is in c:\php

I have tried moving both of these dlls to c:\windows\system but it makes no difference (even with a server restart)


PHP config is attached


Any ideas ?



[attachment deleted by admin]

Link to comment
Share on other sites

thanks mchl.

I realise it says that but I assure you - there is no such file.

Actually I have progressed somewhat with this problem.

I discovered that php uses a "default" set of values if it is having trouble finding the correct php.ini.

This is why it says php.ini is in c:\windows when there isn't one there - it's using the "default" values. a lot of the values in my "config" are different to my ini file for this very reason.

So the problem was that php could not find my php using the path. I found advice on php.net that explains that you need ot set an environment variable called phprc and set its value to c:\php.

I did that and it's now ready the right values out of my php.ini and the functions are loading.

I'm still having trouble getting sql queries to work , but I'm don't know enough of what is wrong to post an update !



Link to comment
Share on other sites

indeed I could have - but I wouldn't have known why it worked !

ONce I created the PHPrc env var, it worked and yes mssql is loaded.

I then had further problems - non of the mssql php functions would work.

Again - found an answer at php.net - needed a later version of ntwdblib.dll. (I'm running SQL 2005 express)

It's working now - but I have noclue about sQL - so need to educate myself  :P

So I'm "Solved"

How do I make this thread as "solved" ?

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.