Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
byterbit
Starting Member
9 Posts |
Posted - 2011-06-12 : 11:52:20
|
Trying to connect via PHP.PHP info reports the dll's loading OKWhen I try to run code ( Sqlsrv_connect()) I get :"Catchable fatal error Argument 2 passed ..." etc.When I try to telnet to port 1433 on the server it quickly times out and SQLCMD on the server reports: "hresult 0x2 level 16 state 1 named pipes provider"which looks like a total failure.I have TCP/IP and Named pipes set on in the Config ManagerAt wits end javascript:insertsmilie(' ') |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-06-12 : 13:38:40
|
Remote connections enabled on the SQL Server?Can you connect using SSMS?Let's see your connection string. |
 |
|
byterbit
Starting Member
9 Posts |
Posted - 2011-06-12 : 18:09:02
|
Thanks for the help.Remote connections are onI can query the db from within SMSSThe connection string (one of MANY tests follows; let me say first that sqlcmd -S(local)\sqlexpressCome back with a >1 , and so seems to work. If I replace (local) above with the ip of the machine(the server, which I'm on) it fails.my PHP test code is now:<?php/*Connect to the local server using Windows Authentication and specifythe AdventureWorks database as the database in use. To connect usingSQL Server Authentication, set values for the "UID" and "PWD" attributes in the $connectionInfo parameter. For example:$connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>"AdventureWorks");*/$serverName = "(local)";//$connectionInfo = array( "Database"=>"testdb");$uid="art";$pwd="ah";$connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>"testdb");$conn = sqlsrv_connect( $serverName, $connectionInfo);if( $conn ){ echo "Connection established.\n";}else{ echo "Connection could not be established.test \n"; die( print_r( sqlsrv_errors(), true));}//-----------------------------------------------// Perform operations with connection.//-----------------------------------------------/* Close the connection. */sqlsrv_close( $conn);?>end of code--------------------------------------------------------------this now returns the failure :Connection could not be established.test Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. [message] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [2]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 2 [code] => 2 [2] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) ) |
 |
|
|
|
|