Edit report at https://bugs.php.net/bug.php?id=31596&edit=1
ID: 31596 Comment by: thair99 at hotmail dot com Reported by: php at thesheath dot com Summary: Unable to connect to an mssql server using mssql_connect Status: Not a bug Type: Bug Package: MSSQL related Operating System: win2003 PHP Version: 4.3.9 Block user comment: N Private report: N New Comment: I am having same error . . . but I am on linux mint < no dll > there is no firewall the username : sa when i use tsql -S/H -U -P everything works ok but not from php Previous Comments: ------------------------------------------------------------------------ [2005-01-18 17:41:39] php at thesheath dot com "Please test the connection with mssql client tools first." This was the first initial test and authentication through Enterprise Manager or QA is fine. "Connecting to mssql servers requires that the ports uses is open in the firewall" There are no FW in use as this is a purely an internal connection. "that the correct user id and password is used" User and password have already been confirmed as correct. "If Integrated NT authentication is used you must specify mssql.secure_connection = On in your php.ini file." The sql servers use Mixed mode authentication with the connection string requiring the sql login user and password, which are correct. This was clear from the fact that web server A could not connect to sql server B, however, using the same script a connection is possible from web server b to sql server b. If the username or password was incorrect, no connection would be possible, from anywhere. Basically is there a problem when trying to connect to an SQL server with mssql_connect when the web server is in a different non trusted domain to the sql server? ------------------------------------------------------------------------ [2005-01-18 17:18:18] f...@php.net Please test the connection with mssql client tools first. Connecting to mssql servers requires that the ports uses is open in the firewall, that the correct user id and password is used (if the SQL server allows SQL server authentication) or that the user account used to execute the PHP script is authneticated on the web server. If Integrated NT authentication is used you must specify mssql.secure_connection = On in your php.ini file. ------------------------------------------------------------------------ [2005-01-18 12:33:00] php at thesheath dot com Summary description changed ------------------------------------------------------------------------ [2005-01-18 12:17:10] php at thesheath dot com Description: ------------ Webserver A is in an active directory VHOSTS, webserver B is in Active directory VHOSTS2. MSSQL Server A is in VHOSTS and MSSQL Server B is in VHOSTS2. If an attempt is made to connect to MSSQL Server A from Webserver B using mssql_connect the connection fails. However, if an attempt is made to connect to MSSQL Server B from Webserver B using mssql_connect, the connection will succeed. This also applies if you change the test around so webserver A connecting to MSSQL Server B. This is purely an internal connection with the only difference in the webservers and ms sql servers is being they're in different domains. Reproduce code: --------------- <?php db_connect(); ?> <?php function db_connect () { $db = mssql_connect ("sql2k230", "*****", "******"); if (!$db) { echo "\nError connecting to SQL Server, User = '" . "" . "', p/w = '" . "" . "' \n\n"; die('Could not connect to server: ' . mssql_get_last_message()); } $result = mssql_select_db ('master', $db); if (!$result) { die('Could not select database: ' . mssql_get_last_message()); } } ?> Expected result: ---------------- The script above should have html included, in which case whatever html is included should be produced in the browser after the db connect has taken place. Or a blank page if using the code only. Actual result: -------------- Warning: mssql_connect(): Unable to connect to server: sql2k227 in e:\******** on line 28 Error connecting to SQL Server, User = '*****', p/w = '****' Could not connect to server: ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=31596&edit=1