Solved

php / mssql connection problem

Posted on 2011-03-09
10
387 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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 
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 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 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

696 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