?
Solved

php / mssql connection problem

Posted on 2011-03-09
10
Medium Priority
?
392 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 17

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

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
 

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 17

Accepted Solution

by:
Chris Harte earned 2000 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 17

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 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