Cannot connect PHP 5.2.9 to SQL Server 2008
Posted on 2010-06-11 11:45 lizhiwen 阅读(738) 评论(0) 编辑 收藏 举报
I have a strange problem while connecting to MSSQL 2008 with php.
First I wrote the code myself and I got error message:
Then I used the code from the Microsoft site:
Yes: The port is 1433;
Yes: The port is open;
Yes: I can connect with telnet;
Yes: The username is correct;
Yes: Also is the password.
Apache server is running local on my workstation.
SQL 2008 is running on remote server (172.17.2.12).
I have no idea what the problem is, and I am sure that the code is correct.
Someone any ideas what this might be?
Thanks in advance;
Lucas Mateijsen
First I wrote the code myself and I got error message:
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 172.16.2.12:1433 in C:\xampp\htdocs\test.php on line 19After googleing for a few hours I found out that with the 2005 version there is some problems with ntwdblib.dll but I cannot find any bugs/problems for this with php 5.2.9 and SQL 2008.
Then I used the code from the Microsoft site:
<?phpBut still I get the error:
// Server in the this format: <computer>\<instance name> or
// <server>,<port> when using a non default port number
$server = '172.16.2.12,1433';
$link = mssql_connect($server, 'Username', 'Password');
if(!$link)
{
die('Something went wrong while connecting to MSSQL');
}
?>
Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 172.16.2.12:1433 in C:\xampp\htdocs\test.php on line 19
Yes: The port is 1433;
Yes: The port is open;
Yes: I can connect with telnet;
Yes: The username is correct;
Yes: Also is the password.
Apache server is running local on my workstation.
SQL 2008 is running on remote server (172.17.2.12).
I have no idea what the problem is, and I am sure that the code is correct.
Someone any ideas what this might be?
Thanks in advance;
Lucas Mateijsen
- Moved byStoyko Kostov - MSFT Friday, August 07, 2009 4:40 PM (From:SQL Server Data Access)