Solved

php / mssql connection problem

Posted on 2011-03-09
10
381 Views
Last Modified: 2012-05-11
Hi,

I'm trying to connect to one of our database installed on a new MSSQL 2008 server and I can't get the connection. It always stop on "couldn't connect to SQL Server". The MSSQL 2008 has the named pipes set to yes and I can reach the server through ODBC connection as well as through the SQL studio management on another computer.

Is it a way to check why we're rejected in some logs somewhere? The webpage is running under a Suse server
<?php
   $MSBIZ_connection = "servername" ;
   $MSBIZ_username = "username" ;
   $MSBIZ_password = "pwd" ;
   $MSBIZ_name = "Prod";

   $sqlconnect = mssql_connect($MSBIZ_connection, $MSBIZ_username, $MSBIZ_password)
	or die("Couldn't connect to SQL Server on [" . $MSBIZ_connection . "]");

   $selected = mssql_select_db($MSBIZ_name, $sqlconnect)
	or die("Couldn't open database [" . $MSBIZ_name . "]"); 

?>

Open in new window

0
Comment
Question by:David_Pazos
  • 5
  • 4
10 Comments
 
LVL 18

Expert Comment

by:lludden
ID: 35082995
Turn on TCP/IP?
0
 
LVL 16

Expert Comment

by:Chris Harte
ID: 35083248
My first suggestion would be to use the odbc function

http://uk3.php.net/manual/en/function.odbc-connect.php

Otherwise, have you made sure the MSSQL extension is enabled by adding

extension=php_mssql.dll

to your php.ini. (Because the default setting  is not enabled).
0
 

Author Comment

by:David_Pazos
ID: 35083323
Hi,

thanks for your suggestions...

- the TCP/IP is already on.

- the mssql is available as it was working before we change the database. When I do the php -m, it appears as module loaded.

any other ideas?

David
0
 
LVL 16

Expert Comment

by:Chris Harte
ID: 35083628

Your version of ntwdblib.dll may need updating.

You can download the latest version via this page
http://www.helpspot.com/helpdesk/index.php?pg=kb.page&id=13
0
 

Author Comment

by:David_Pazos
ID: 35084716
Hi

thanks for your answer but as mentioned in your link, it's to update the file in the server hosting the PHP. But our php server runs under linux, do you know if that kind of file may exists for linux? shall I update maybe our php version?

ntwdblib.dll - The most common issue is that you do not have the ntwdblib.dll file installed in your PHP directory (where php.exe is, or sometimes placing it in the ext directory works as well). This library can be found with your Enterprise Manager dll's or in your SQL servers system32 folder. It's generally best to take the file from the server where SQL Server is installed.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:David_Pazos
ID: 35084857
Hi

Forget my last post about updating the linux php. I've tried on another of our server using a recent version of php and IIS and the problem was the same. But we tried to connect to another SQL server with a differente database and we manage to connect without any problems....

could it be a problem of version, hotfix or anything else??? does it sounds familiar to anyone?
David
0
 
LVL 16

Accepted Solution

by:
Chris Harte earned 500 total points
ID: 35086319
A bit of googling and it looks like the only ways to do it are FreeTDS or ODBC.

0
 

Author Comment

by:David_Pazos
ID: 35133172
mmmmmm I think that's the solution... freetds. Do you have any idea how it works?
0
 
LVL 16

Expert Comment

by:Chris Harte
ID: 35138875
Never done it myself. Ubuntu does a virtual package of PHP5-mssql which uses the sybase package, this seems to be the most well documented root.
0
 

Author Comment

by:David_Pazos
ID: 35149021
2 words...
Thank You! ))
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now