p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Connection to a MSSQL Database.


Message #1 by "Peter Lanoie" <planoie@e...> on Mon, 22 Jan 2001 14:30:45 -0500
Let me precursor this with the following disclaimer...

I'm going to install MySQL in the very near future, but in the mean time, I

want to get PHP talking to my MSSQL Database. Once I'm on MySQL, I'm sure I

won't have any problems. ;-)



I installed PHP 4.04 on a Win2k box with MSSQL 7.0

The php side of things seems to be working fine so far.

I'm trying to follow directions to getting connected to the MSSQL db but no

luck so far.



Here is a link to some instructions I've been using...

http://www.php.net/manual/en/function.mssql-connect.php



There is continual reference to the "php_mssql70.dll" as well as a

"ntwdblib.dll".

I found the first and it's there, the second comes with MSSQL so I don't

think that is the problem (it's in winnt\system32).



This is what happens when I call the page:



First, I get this pop up window warning on the server:

"Unable to load dynamic library 'php_mssql70.dll' - The specified procedure

could not be found."



After clicking ok on that warning...

I get this page error:



X-Powered-By: PHP/4.0.4pl1 Content-type: text/html

Fatal error: Call to undefined function: mssql_connect() in

D:\wwwdev\peter\phpdbtest.php on line 8

PHP Warning: Unable to load dynamic library './php_mssql70.dll' - The

specified procedure could not be found. in Unknown on line 0



Line 8 is:

MSSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED TO

RESPOND.");



I have tried moving the "php_mssql70.dll" dll around, but that doesn't seem

to affect it.

I have also set up the \winnt\php.ini file with the line

"extension=php_mssql70.dll" under the "Windows Extensions" section in there

and not commented. Also, I changed the extension_dir to blank instead of

"./". Otherwise, the php.ini file is as is from the installation.



What am I missing, or doing wrong?



Thanks.



Peter



Message #2 by "Peter Lanoie" <planoie@e...> on Tue, 23 Jan 2001 18:43:47 -0500
I'm following up on my own post....



I got things figured out. I tossed the mssql connect technique out the

Windows (Bah!) and created an ODBC entry to the SQL database.

Then I used the odbc_connect and other odbc_xxx functions to connect, run

the query and do other things.

Somethin that I noticed while working on it was that it didn't work until i

had the username and password in the connect function.

	$db = odbc_connect($hostname, $username, $password);

I tried it at first without them, and it wouldn't work.  Now, I'm still a

little uncertain of how ODBC works, but I have been under the impression

that the ODBC connection contained the login information, and you didn't

need it in the DB connection from the code. I typically avoid using ODBC

DSNs just cause DSN-less connections are so much easier to deal with from

machine to machine. I do this with ASP, but this is a beginner's list, so

draw your own conclusions on my PHP skills, ;-)



I'd be interested to hear from anyone with info on ODBC functionality, or

info on DB connectivity in PHP. (Perhaps I should move to a different p2p

list :)



Thanks.



Peter



-----Original Message-----

From: Peter Lanoie [mailto:planoie@e...]

Sent: Monday, January 22, 2001 2:31 PM

To: beginning php

Subject: [beginning_php] Connection to a MSSQL Database.





Let me precursor this with the following disclaimer...

I'm going to install MySQL in the very near future, but in the mean time, I

want to get PHP talking to my MSSQL Database. Once I'm on MySQL, I'm sure I

won't have any problems. ;-)



I installed PHP 4.04 on a Win2k box with MSSQL 7.0

The php side of things seems to be working fine so far.

I'm trying to follow directions to getting connected to the MSSQL db but no

luck so far.



Here is a link to some instructions I've been using...

http://www.php.net/manual/en/function.mssql-connect.php



There is continual reference to the "php_mssql70.dll" as well as a

"ntwdblib.dll".

I found the first and it's there, the second comes with MSSQL so I don't

think that is the problem (it's in winnt\system32).



This is what happens when I call the page:



First, I get this pop up window warning on the server:

"Unable to load dynamic library 'php_mssql70.dll' - The specified procedure

could not be found."



After clicking ok on that warning...

I get this page error:



X-Powered-By: PHP/4.0.4pl1 Content-type: text/html

Fatal error: Call to undefined function: mssql_connect() in

D:\wwwdev\peter\phpdbtest.php on line 8

PHP Warning: Unable to load dynamic library './php_mssql70.dll' - The

specified procedure could not be found. in Unknown on line 0



Line 8 is:

MSSQL_CONNECT($hostname,$username,$password) or DIE("DATABASE FAILED TO

RESPOND.");



I have tried moving the "php_mssql70.dll" dll around, but that doesn't seem

to affect it.

I have also set up the \winnt\php.ini file with the line

"extension=php_mssql70.dll" under the "Windows Extensions" section in there

and not commented. Also, I changed the extension_dir to blank instead of

"./". Otherwise, the php.ini file is as is from the installation.



What am I missing, or doing wrong?



Thanks.



Peter






  Return to Index