?
Solved

php / mssql connection problem

Posted on 2011-03-09
10
Medium Priority
?
388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

762 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