Solved

PHP - Can't get the MS drivers to work on IIS7 and SQL 2005 - am seriously desperate here!!!

Posted on 2010-08-20
7
1,301 Views
Last Modified: 2013-12-13
I'm in a really bad fix.  I have an application that must be done with a week and I cannot get the MS PHP SQL drivers to work for me at all.  They show up in phpinfo() and are in the php stream.  But when I try to use them to connection I get:

[see code block below]

Now, I don't have SQL 2008, just 2005, but I thought I saw somewhere that I needed these drivers because of Server 2008.  I'm going absolutely nuts trying to get this working.  I've been told that if I miss the deadline, that 'heads will roll'.

If I could offer a 1000 points I would - so help me out here....

With Server 2008/IIS7 and SQL 2005:

1. Do I need to use the Microsoft PHP SQL drivers to access a SQL 2005 db throught IIS7?

2. If not, are there any special tricks to using the MSSQL on that plat form.  I've got a development environment running with server 2003 and sql2005 and mssql works fine, but the other day, before I ran down the new driver rabbit hole, I couldn't connect with php_mssql.dll either. The driver is currently not loading and I don't want to run a reset during the middle of the date. I've restarted the web server and recycled the app pools with no effect yet.

3. Also, I've found that 'net stop ...' is no longer an option in IIS7.  Is there a new command for the same thing or just make do with iisreset?

Thanks in advance for any help -
Unable to connect.
Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )

Open in new window

0
Comment
Question by:saabStory
  • 3
  • 3
7 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 375 total points
ID: 33488249
You need to tell which version of PHP you're using and show us your connection code although you can hide you private details like username and password.  Are you using the same code on both servers?
0
 
LVL 8

Assisted Solution

by:Jessie Gill, CISSP
Jessie Gill, CISSP earned 125 total points
ID: 33488362
You could take the mssql dll files from PHP 5.2 and use them if you are using php5.3.  I am assuming you know how to edit the php.ini file to allow the dll to laod.  after you use the DLL restart IIS.  I am also using iis7 php and mssql.
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 375 total points
ID: 33488412
Did you copy "ntwdblib.dll" to the Windows 7 computer?  Put in the PHP root and System32.
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:saabStory
ID: 33488713
Sorry - in way too much of a hurry

connection is below in the code box.  Am using PHP 5.2.14 with FastCGI.  Same code on both servers.  My server is server 2003 and the work production box is server2008.

I haven't tried the ntwdblib.dll yet.  But that reminded me that I forgot to copy my working copy of the dll.  I've done that and am getting MSSQL showing now but still can't connect with mssql:

"PHP Warning:  mssql_connect() [function.mssql-connect]: Unable to connect to server:  10.10.10.113 in [server path].phpinfo.php on line 7" - which is where I make the connection.

I've pinged the SQL server from the box and get a reply so the web server can see the SQL server.




<?php
	$myServer="serverIP";
	$myUID = "loginName";
	$myPW = "loginPassword";
	$myDB = "database";
	$conn = mssql_connect($myServer,$myUID,$myPW)
	or die("Couldn't connect to SQL Server on ".$myServer." because: ".mssql_get_last_message());

	$db = mssql_select_db($myDB, $conn)
	or die("Couldn't open database ".$myDB);

	mssql_query ( 'SET TEXTSIZE 65536' , $conn );
	ini_set ( 'mssql.textlimit' , '65536' );
	ini_set ( 'mssql.textsize' , '65536' ); 
?>

Open in new window

0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 375 total points
ID: 33489041
According to a couple of other questions here, "ntwdblib.dll" is a required part of mssql PHP files.  Worse yet, there are apparently two versions: http://www.php.net/manual/en/mssql.requirements.php
0
 

Author Comment

by:saabStory
ID: 33489465
I've got a version that has been working for me for ages and I've never had any difficulty at all getting this to work before.  This is a new job for me and the network is very virtualized and different from what I've used to.  In desperation, I created a DSN on the web server and was able to connect with ODBC but I'm not up on the odbc commands like I am with the mssql ones.  I've got to wonder if there's something on the SQL server that is preventing me from connecting even though I'm using the same login as our DNN site.  

I'll have to ask the IT director if there's anything there that would prevent such a connection.
0
 

Author Closing Comment

by:saabStory
ID: 33835325
Sorry to let this hang for so long guys - got busy, etc, etc.  Never did find a solution - created a DSN and am using the ODBC drivers.  Pretty crude but it works right now and buys me some time down the road to resolve it once and for all.

Since you both took time to answer me, I'll just divide points by the number of responses, if that's okay.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP and google maps 13 45
Loop through multiple arrays 13 28
Fulfillment API php code sample 1 41
How to change the link of an image using md5 in php ? 3 32
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question