BIG PROBLEM FOUNDED AND FIXED, ABOUT function.mssql-connect in Win 7 + WAMP

March 15th, 2012 by dr.emi

I just googling for more than 5 hours for this problem:

Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: XXXXXXX in D:\xxxxx.xxx\xxxx.php on line 16
Couldn't connect to SQL Server on XXXXXXX

Actually, even you has configure with right setting for mssql from WAMP Server / any server that support mssql (absolutly for 5.2.x), this errror will still become A GHOST for you. Since, the error is not specific. You will ask WHY?

Everyone, this is just problem about Access Control from Window 7 / vista. So then, after google, I found this statement, that very helpfull for everyone that get STRESS with MS SH*T Express Installation with PHP:

========================================================

Hi, just trying to save some time for those using windows Vista + WAMP 5.1.7 (Apache as the HTTP server, not IIS 7)

I was having trouble connecting to SQL Server 2005 Express and I hope the following procedure helps someone out there.

0. Stop all services from WAMP

1. get ntwdblib.dll version 2000.80.194.0 and copy it to the following locations:
a) wamp\php\
b) wamp\Apache2\bin\
c) windows\system32\

2. Configure SQL Server to accept TCP connections and Named Pipes as discussed in earlier posts. (no need to change port settings)

3. Configure SQL Server for Mixed mode authentication and remember the password you set for sa

4. Restart SQL Server Service

5. Open wamp\php\php.ini and set the mssql.secure_connection = On

6. Right-click your wamp folder and click on Properties. Got to the security tab and click on Edit… Now click on Add and type in ‘Everyone’ without the single quotes

7. Once you added ‘Everyone’ make sure you check the Full Control checkbox in the permissions list

8. Click on start all services from the WAMP menu

to connect, do something like the following:
$cnMsSQL = mssql_connect(‘.\SQLEXPRESS’, ‘sa’, ‘yourpassword’) or trigger_error(mssql_get_last_message(),E_USER_ERROR);

Well, that’s it… that’s how I made it work. Hope that this solves someone’s issue

DOWNLOAD ntwdblib.dll version 2000.80.194.0 HERE:

http://www.nodevice.com/dll/ntwdblib_DLL/item12329.html

Source: http://www.xuchao.org/docs/php/function.mssql-connect.html
Comment from: mariodivece at yahoo dot com
========================================

AND NOW MY MS SQL SUCCESSFULLY RUNNIG WELL WITH PHP 5.2.5

Popularity: 5% [?]

Database Configuration for MsSQL Server 2000 or higer in CakePHP 1.3.x or higher

March 11th, 2012 by dr.emi

I just found today, how to the best configuration for DBO Driver of MsSQL in CakePHP 1.3.7

First, I have try to make a connection to SQL Server 2000, 2005, and 2008. The result is always:

Warning (2): mssql_connect() [function.mssql-connect]: Unable to connect to server: 192.168.137.1\SQLEXPRESS,1433 [CORE\cake\libs\model\datasources\dbo\dbo_mssql.php, line 154]
Warning (2): mssql_select_db() expects parameter 2 to be resource, boolean given [CORE\cake\libs\model\datasources\dbo\dbo_mssql.php, line 159]

After done for googling in few day(s), I just found a bug based on error above, in

CORE\cake\libs\model\datasources\dbo\dbo_mssql.php, line 154

It looks likely, configuration is always overwrite into this line. But after read an article about port problem for mssql driver in cakephp (forgoten about where is the article link), I try to change it to port => ”

And the result is still not connected, although I have try too in native php. And it’s works with simple line:

$myServer = "192.168.137.1\SQLEXPRESS"; //I used sql server 2008
$myUser = "sa";
$myPass = "xxx";
$myDB = "mesin_finger"; 

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer"); 

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB");

Next, trouble shoot continue to line before 154 in dbo_mssql.php: CORE\cake\libs\model\datasources\dbo\dbo_mssql.php

And the magic has come, after change $config['host'] to direct string ’192.168.137.1\SQLEXPRESS’, it’s WORK!
So, I just found the bug:

If I use $port as complete string in mssql_connect or mssql_pconnect, connection will not success, since in line 147 of dbo_mssql.php, I found this line:

} elseif ($config['port'] === null) {

It’s mean, we must set port configuration in database.php to null, NOT IN STRING value. The option is only null and numeric value.

Here are my database.php configuration:

var $attDbMsSqlServer = array(
                'driver' => 'mssql',
                'persistent' => false,
                'host' => '192.168.137.1\SQLEXPRESS',
                'login' => 'sa',
                'password' => 'xxx',
                'database' => 'mesin_finger',
                'prefix' => '',
                'encoding' => 'utf-8',
                'port' => null
        );

GOOD LUCK!!

Popularity: 20% [?]

 
 
 
 
Category
stack

Switch to our mobile site