Connection to MSSQL from PHP Framework Kohana

487 views Asked by At

I'm trying to connect a php application (using framework Kohana) with Microsoft SQL Server and It fails!!!


Technical Context:

  • Microsoft Windows Server 2012 R2 Standard.
  • Framework Kohana v2.3.4.
  • XAMPP Server v1.7.1:
    • Apache v2.2.11.
    • PHP 5.2.9.
  • Microsoft SQL Server 2012 (Express Edition).
  • Microsoft .NET Framework v4.0.20219.42000.


Problem Summary:

  • Apparently, the mssql driver is OK! I checked if the folder "...\xampp\php\ext\" has "php_mssql.dll" and if there are a reference with it in php.ini file... and yes!!! Everything are Ok!
  • I don't have any authentication problem in Microsoft SQL Server Management Studio (I'm using a SQL Server Authentication).1
  • I have problems in the Kohana database configuration (I'm using the same authentication data of Management Studio). Where I added the following:

    $config['testing'] = array
    (
     'benchmark' => TRUE,
     'persistent' => TRUE,
     'connection' => array
     (
      'type' => 'mssql',
      'user' => 'username',
      'pass' => 'password',
      'host' => 'SERVERNAME\SQLEXPRESS',
      'port' => FALSE,
      'socket' => FALSE,
      'database' => 'database_name'
     ),
     'character_set' => 'utf8',
     'table_prefix' => '',
     'object' => TRUE,
     'cache' => FALSE,
     'escape' => TRUE
    );

But, the web browser answer is "mssql_connect() [function.mssql-connect]: Unable to connect to server: SERVERNAME\SQLEXPRESS".

  • I tried changing the hostname (I think that the problem is there): without '\SQLEXPRESS' and using the machine IP address.

  • I tried setting FALSE the user and pass attributes in the kohana database configuration.

It's important to say: this machine is a testing server! I could connect the application with a sql server in a development machine. So, I tried to connect the development machine application with the testing machine database server and I got the same error. The unique technical differences between the testing and development machines are in the development machine I'm using SQL SERVER 2016 and Windows 10. In the development machine I authenticate in the Management Studio with the "Windows Authentication" and I set FALSE the user ans pass in the kohana database configuration.

What is it could be the problem? Thanks!

1

There are 1 answers

0
Arturo Mendoza On BEST ANSWER

The solution is set the filestream properties (in Sql Server Configuration Manager -> SQL Server Services -> Right click on SQL Server (SQLEXPRESS) -> Properties -> FILESTREAM), enabling filestream for Transact-SQL and file IO accesses and allowing remote clients access to FILESTREAM data.