A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearWhat is the correct PHP configuration to connect to MS SQL 2000/2005? - page 1
User InfoPosts
What is the correct PHP configuration to connect to MS SQL 2000/2005?#1
I have a number of servers running PHP 5.2.6 (non-thread-safe build) on Windows 2003/IIS6 utilising FastCGI.

I(m having some issues connecting to MS SQL 2000/2005 (MySQL connectivity is working fine, ASP/ASP.NET scripts can connect to MS SQL successfully as well). One solution suggests copying the SQL Client Tools ntwdblib.dll file to the PHP extensions folder or installing all of the SQL Client Tools on the web server (which I(m reluctant to do).

Another solution suggested is to use the Microsoft SQL Server 2005 Driver for PHP. This looks fine for writing greenfield apps but for applications such as phpBBS or WordPress this doesn(t appear to work.

For example, the following script:

<?php 
$host = "mssqlhost";
$user = "phpbb2";
$password = "phpbb2";

$connect_sql_server = mssql_connect($host, $user, $password);
?>


Fails with:


PHP Warning: mssql_connect()
[function.mssql-connect]: Unable to
connect to server: mssqlhost in
E:\AppsDev.NET_UK_Minds\phpSqlNC\www\test.php
on line 6


The goal is to allow PHP scripts to connect to both SQL 2000 and SQL 2005 which are running on different servers. I should also add that upgrading to a later version of PHP isn(t an option at this time.

What is the correct way to configure PHP on Windows 2003/IIS6 to connect to SQL 2000/2005?

posted date: 2009-04-14 05:12:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-14 05:12:01


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#3
The fact that you get that message seems like it's working. Are you sure the host is OK (your typing MYSql host and using MSSql_connect)? Can you connect to the server with a client (to test connectivity).

posted date: 2009-04-14 05:17:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#4
Connectivity is fine and verified using SQL management studio. This seems to be a known issue with PHP + MS SQL but there seems to be so many different stories about how to solve.

posted date: 2009-04-14 05:23:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#5
After trying various (solutions( it turns out that the problem was solved simply by replacing the ntwdblib.dll file in the PHP executables folder.There is no need to install any of: SQL Native Client, SQL Client Tools or Microsoft SQL Server 2005 Driver for PHP, as many dead ends have suggested.All that needs done is to ensure that ntwdblib.dll version 2000.80.2039.0 is dropped into the c:\php folder (or wherever you(ve installed/uncompressed PHP to) and then reset IIS. The PHP docs suggest copying ntwdblib.dll to %SYSTEMROOT%\System32 which doesn(t work and they also suggest that this will only support named pipes which is also wrong.I haven(t tried to see if a later version of ntwdblib.dll works or not, but 2000.80.2039.0 works for me.

posted date: 2009-04-14 10:11:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#6
The PHP docs would suggest system32 because this can be the default PHP location. Do you know of the official site to get the ntwdblib.dll from? I googled and found one but would like to know where to get the latest version. I had enabled MSSQL.dll in php.ini but when going to cmd and doing php -m to list all modules, an error box appeared saying I was missing ntwdblib.dll which led me here :D

posted date: 2009-04-29 08:28:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#7
We have lots SQL 2000 SP4 on site so I basically grabbed it from one of the servers and copied to the web server.

posted date: 2009-04-29 11:27:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#8
Not really an answer, but more helpful information... The version of ntwdblib.dll (2000.2.8.0) that comes with latest php 5.2.X works great with Apache and MSSQL (2008). I have a copy of the DLL from the 2000.80.X.X versions and it is newer than what comes with PHP. I don(t know if this makes it better. The "mssql_" functions are not included in the official msft php mssql driver. They have changed them to a different naming convention. ("sqlsrv_") That link you posted is version 1.0 but they are already on version 1.1. The "mssql_" functions require that the ntwdblib.dll be present.

posted date: 2009-10-14 06:46:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#9
I got my issues resolved and have been following developments regarding MS SQL and the official drivers. Thanks for the info.

posted date: 2009-10-14 08:19:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#10
No problem. Just FYI, it appears that all the "mssql_" functions have been dropped in 5.3 because this file is not included currently.

posted date: 2009-10-14 08:57:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#11
Apache 2.2.14 /PHP 5.2.12/MS-SQL 2008 integrationDownload Apache 2.2.14 for Windows Installer package 2008 32 bithttpd DOT apache DOT org/download.cgi --> apache_2.2.14-win32-x86-no_ssl follow the defaults when installing Apachestop Apache 2.2 serviceDownload PHP 5.2.12 Windows Zip package for Windows 2008 32 bit;(VC6 Thread Safe version needed for PHP used as an Apache module).windows DOT php DOT net/download/ --> php-5.2.12-Win32-VC6-x86.zip- Extract the archive to C:\PHP - Verify the installation: C:\PHP>php -v- set the Environment Variable PHPRC=C:\PHP- Rename (C:\PHP\php.ini-recommended( to (C:\PHP\php.ini(- Edit C:\PHP\php,ini file:modify: extension_dir = "C:\PHP\ext"uncomment: extension=php_mssql.dllAdd the lines below to "C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf"PHPIniDir "C:/PHP/"LoadModule php5_module "C:/PHP/php5apache2_2.dll"AddHandler application/x-httpd-php .phpAdd the lines below to "C:\Program Files\Apache Software Foundation\Apache2.2\conf\mime.types"application/x-httpd-php phpapplication/x-httpd-php-source phpsEnsure that phpinfo.php file with the content: is in the folderC:\Program Files\Apache Software Foundation\Apache2.2\htdocsStart Apache 2.2 serviceVerification of Apache/PHP integration: http://localhost/phpinfo.php --> (PHP Version 5.2.12( info shows upVerification whether mssql( module is loaded: c:\php\php -mAll works like a charm ... no additional steps needed.

posted date: 2010-02-11 11:14:00


Re: What is the correct PHP configuration to connect to MS SQL 2000/2005?#12
Version 2000.80.194.0 worked for me too (PHP 5.2, SQL Server 2008 R2 Express)

posted date: 2012-04-12 08:16:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.