Страница 1 из 1

Проблема с MSSQL на php 5.2

Добавлено: 2012-05-04 13:23:38
cubespace
Есть сервер FreeBSD 8.1
Стоит : apache22+php5.2

Есть другой сервер с виндой 2003 и MSSQL server 2005

Нужно вывести данные из базы на веб сервер на FreeBSD (192.168.5.3) из Винды MSSQL server 2005 (192.168.5.1)
У нас в компании, стоит серв с Windows server 2003 и на нем база MSSQL server 2005, для работы с одной большой прогой (разработчики которой писали ее под винду и базу тоже), каждый день много людей с ней работают!
второй сервер: FreeBSD 8.1 (почта, самба, веб сервер), на этом серве нужно открывать типа сайт, через которым можно будет посмотреть данные из базы MSSQL server 2005!

Модули подключил для PHP
Изображение
доступ на сервер баз даных есть из других машин, и по telnet все открыто!

Код: Выделить всё

# telnet 192.168.5.1 1433
Trying 192.168.5.1...
Connected to localhost.
Escape character is '^]'.

Но при конекте через сайт, получаеться такое :

Код: Выделить всё

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 192.168.5.1 in /usr/local/www/apache22/data/test/index2.php on line 5
Something went wrong while connecting to MSSQL

Код: Выделить всё

<?php
$server = '192.168.5.1';

// Connect to MSSQL
$link = mssql_connect($server, 'sa', 'pass');

if (!$link) {
    die('Something went wrong while connecting to MSSQL');
}
?>
В нете нашел что ошибка в mssql_connect, что решить ее можно для виндового веб сервера :
PHP Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: servername

It turns out that my connection string was 100% correct however the version of the ntwdblib.dll file on my PHP box was not compatibile with certain recent versions of SQL Server. According to the PHP website ntwdblib.dll is required for the PHP MSSQL extension to work:

The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from \winnt\system32 on the server to \winnt\system32 on the PHP box. Copying ntwdblib.dll will only provide access through named pipes. Configuration of the client will require installation of all the tools.

It seems that for whatever reason the very latest installs of PHP include a version of ntwdblib.dll that will not work with SQL Server 2003, SQL Server 2005 and as far as I’m aware SQL Server Express. The version of ntwdblib installed is likely to be 2000.2.8.0 when what you need to have to talk to recent versions of SQL Server is 2000.80.194.0. This file can actually be present in locations other than winnt\system32 depending on your platform and installation setup so I suggest you do a search for it, check the version and if it doesn’t end it 80.194.0 download the latest version from the UserScape.com site and use it to overwrite the existing version. In my case I installed PHP as a CGI on Windows Server 2003 so the file was present directly in the PHP folder. When I updated it and tried my code again everything worked fine, including the original PHP DAL DB:connect call.

In the end it turned out my problems were nothing to do with the PEAR DB module but were related to PHPs SQL Server functions. If your still having problems connecting to SQL Server from PHP I suggest you visit the relevant PHP page located at http://ie2.php.net/function.mssql-connect which contains a lot of user contributed information about ntwdblib.dll and other issues which may be causing your problems and associated pain.

Как мне решить проблему?

Re: Проблема с MSSQL на php 5.2

Добавлено: 2012-05-04 14:23:18
manefesto

Re: Проблема с MSSQL на php 5.2

Добавлено: 2012-05-04 14:45:46
cubespace
Спасибо большое! Все получилось! Звените что сразу не посмотрел!