Solved

php / mssql connection problem

Posted on 2011-03-09
10
380 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
Comment Utility
Turn on TCP/IP?
0
 
LVL 16

Expert Comment

by:Chris Harte
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:David_Pazos
Comment Utility
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
Comment Utility
A bit of googling and it looks like the only ways to do it are FreeTDS or ODBC.

0
 

Author Comment

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

Expert Comment

by:Chris Harte
Comment Utility
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
Comment Utility
2 words...
Thank You! ))
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.

763 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

12 Experts available now in Live!

Get 1:1 Help Now